blob: 496b8d32ad7537fdf9fa44302f13ad0605a47208 (
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
|
let
lib = import ../../lib // {
isLocalTarget = let
origin = lib.mkTarget "";
in target:
target.host == origin.host &&
target.user == origin.user;
};
in
{ nix, openssh, populate, writeDash, writeJSON }: let
populate' = name: { source, target }:
writeDash "${name}-populate" ''
set -efu
source=${writeJSON "${name}-source.json" source}
target=${target.user}@${target.host}:${target.port}${target.path}
exec ${populate}/bin/populate "$target" < "$source"
'';
in {
writeDeploy = name: { source, target }: let
target' = lib.mkTarget target;
in
writeDash name ''
set -efu
${populate' name { inherit source; target = target'; }}
${openssh}/bin/ssh \
${target'.user}@${target'.host} -p ${target'.port} \
nixos-rebuild switch -I ${target'.path}
'';
writePopulate = name: { source, target }:
populate' name {
inherit source;
target = lib.mkTarget target;
};
writeTest = name: { source, target }: let
target' = lib.mkTarget target;
in
assert lib.isLocalTarget target';
writeDash name ''
set -efu
${populate' name { inherit source; target = target'; }}
${nix}/bin/nix-build \
-A config.system.build.toplevel \
-I ${target'.path} \
--arg modules '[<nixos-config>]' \
--no-out-link \
--show-trace \
'<nixpkgs/nixos/lib/eval-config.nix>'
'';
}
|