-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefault.nix
59 lines (49 loc) · 1.21 KB
/
default.nix
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
nixpkgs: pkgs: lib:
let
inherit (pkgs) system;
inherit (pkgs.lib) getExe;
mkKexec = crossSystem:
let
pkgsCross = import nixpkgs {
localSystem = system;
inherit crossSystem;
};
pkgsTarget = import nixpkgs {
system = crossSystem;
};
kexec = pkgsCross.writeShellApplication {
name = "kexec";
runtimeInputs = with pkgsTarget; [
curl
gnutar
iproute2
jq
];
text = lib.subsT ./kexec.sh {
system = crossSystem;
};
};
bundle = pkgs.runCommand "kexec-bundle" { } ''
cat <<-\EOF > $out
d="$(mktemp -d)"
tail -n+6 "$0" | tar xz -C "$d" --strip-components 2
mkdir -p /nix/store
mount -t overlay -o "lowerdir=/nix/store:$d" aquaris-kexec /nix/store
exec ${getExe kexec} "$@"
EOF
tar cz -T ${pkgs.writeClosure kexec} >> $out
'';
in
bundle;
deploy = pkgs.writeShellApplication {
name = "deploy";
runtimeInputs = with pkgs; [
openssh
];
text = lib.subsT ./deploy.sh {
kexec-amd = mkKexec "x86_64-linux";
kexec-arm = mkKexec "aarch64-linux";
};
};
in
deploy