2018-09-07 17:55:22 +02:00
|
|
|
{ name }: let
|
2018-06-07 08:24:56 +02:00
|
|
|
inherit (import ../krebs/krops.nix { inherit name; })
|
2018-04-05 19:31:39 +02:00
|
|
|
krebs-source
|
|
|
|
lib
|
|
|
|
pkgs
|
|
|
|
;
|
|
|
|
|
2018-11-21 04:58:55 +01:00
|
|
|
|
2019-03-26 14:39:52 +01:00
|
|
|
source = { test }: lib.evalSource ([
|
2018-11-28 21:30:46 +01:00
|
|
|
(krebs-source { test = test; })
|
2018-04-05 19:31:39 +02:00
|
|
|
{
|
2018-05-12 15:53:04 +02:00
|
|
|
nixos-config.symlink = "stockholm/lass/1systems/${name}/physical.nix";
|
2020-01-11 21:03:08 +01:00
|
|
|
nixpkgs-unstable.git = {
|
2020-10-18 19:07:09 +02:00
|
|
|
url = "https://github.com/nixos/nixpkgs";
|
2020-01-11 21:03:08 +01:00
|
|
|
ref = (lib.importJSON ../krebs/nixpkgs-unstable.json).rev;
|
2020-10-18 19:07:09 +02:00
|
|
|
shallow = true;
|
2020-01-11 21:03:08 +01:00
|
|
|
};
|
2018-04-05 19:31:39 +02:00
|
|
|
secrets = if test then {
|
2018-09-07 16:55:37 +02:00
|
|
|
file = toString ./2configs/tests/dummy-secrets;
|
2018-04-05 19:31:39 +02:00
|
|
|
} else {
|
|
|
|
pass = {
|
2020-01-11 21:03:42 +01:00
|
|
|
dir = "${lib.getEnv "HOME"}/sync/pwstore";
|
2018-04-05 19:31:39 +02:00
|
|
|
name = "hosts/${name}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
2021-10-23 19:03:02 +02:00
|
|
|
(if lib.pathExists (./. + "/1systems/${name}/source.nix") then
|
2019-10-14 16:00:07 +02:00
|
|
|
import (./. + "/1systems/${name}/source.nix") { inherit lib pkgs test; }
|
|
|
|
else
|
|
|
|
{}
|
|
|
|
)
|
|
|
|
]);
|
2018-04-05 19:31:39 +02:00
|
|
|
|
|
|
|
in {
|
2018-11-20 01:16:22 +01:00
|
|
|
|
2021-10-26 21:00:22 +02:00
|
|
|
deploy = { target ? "root@${name}/var/src" }: pkgs.krops.writeCommand "deploy" {
|
|
|
|
command = targetPath: ''
|
|
|
|
|
|
|
|
set -fu
|
|
|
|
|
|
|
|
outDir=$(mktemp -d)
|
|
|
|
trap "rm -rf $outDir;" INT TERM EXIT
|
|
|
|
|
|
|
|
nix build \
|
|
|
|
-I "${targetPath}" \
|
|
|
|
-f '<nixpkgs/nixos>' config.system.build.toplevel \
|
|
|
|
-o "$outDir/out"
|
|
|
|
|
|
|
|
$outDir/out/bin/switch-to-configuration switch
|
|
|
|
'';
|
2018-04-05 19:31:39 +02:00
|
|
|
source = source { test = false; };
|
2021-10-26 21:00:22 +02:00
|
|
|
allocateTTY = true;
|
2018-10-23 15:45:38 +02:00
|
|
|
inherit target;
|
2018-04-05 19:31:39 +02:00
|
|
|
};
|
|
|
|
|
2018-11-20 01:16:22 +01:00
|
|
|
# usage: $(nix-build --no-out-link --argstr name HOSTNAME --argstr target PATH -A populate)
|
|
|
|
populate = { target, force ? false }: pkgs.populate {
|
|
|
|
inherit force;
|
|
|
|
source = source { test = false; };
|
|
|
|
target = lib.mkTarget target;
|
|
|
|
};
|
|
|
|
|
2018-09-09 10:23:20 +02:00
|
|
|
# usage: $(nix-build --no-out-link --argstr name HOSTNAME --argstr target PATH -A test)
|
|
|
|
test = { target }: pkgs.krops.writeTest "${name}-test" {
|
2018-10-09 13:48:52 +02:00
|
|
|
force = true;
|
2018-09-09 10:23:20 +02:00
|
|
|
inherit target;
|
2018-04-05 19:31:39 +02:00
|
|
|
source = source { test = true; };
|
2018-09-07 17:40:10 +02:00
|
|
|
};
|
2018-04-05 19:31:39 +02:00
|
|
|
}
|