blob: ff32b11b4e7d9c32bd2185199078fb9f57fbf365 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
let
lib = import ../../lib;
in
{ exec, nix, openssh, populate, writeDash }: rec {
build = target:
exec "build.${target.host}" rec {
filename = "${openssh}/bin/ssh";
argv = [
filename
"-l" target.user
"-p" target.port
"-t"
target.host
(lib.concatStringsSep " " [
"nix build"
"-I ${lib.escapeShellArg target.path}"
"--no-link -f '<nixpkgs/nixos>'"
"config.system.build.toplevel"
])
];
};
rebuild = args: target:
exec "rebuild.${target.host}" rec {
filename = "${openssh}/bin/ssh";
argv = [
filename
"-l" target.user
"-p" target.port
target.host
"nixos-rebuild -I ${lib.escapeShellArg target.path} ${
lib.concatMapStringsSep " " lib.escapeShellArg args
}"
];
};
writeDeploy = name: { force ? false, source, target }: let
target' = lib.mkTarget target;
in
writeDash name ''
set -efu
${populate { inherit force source; target = target'; }}
${rebuild ["dry-build"] target'}
${build target'}
${rebuild ["switch"] target'}
'';
writeTest = name: { force ? false, source, target }: let
target' = lib.mkTarget target;
in
assert lib.isLocalTarget target';
writeDash name ''
set -efu
${populate { inherit force source; target = target'; }} >&2
NIX_PATH=${lib.escapeShellArg target'.path} \
${nix}/bin/nix-build \
-A system \
--keep-going \
--no-out-link \
--show-trace \
'<nixpkgs/nixos>'
'';
}
|