-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpxe-installer.nix
77 lines (62 loc) · 1.62 KB
/
pxe-installer.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{ writeScript
, bash
, pixiecore
, retry
, curl
# nixpkgs for the installer image
, pkgs
, lib
# The node to build installer for
, node
, ...
}:
with lib;
let
installer = pkgs.nixos [
(
{ modulesPath
, lib
, ...
}:
{
imports = [
"${modulesPath}/installer/netboot/netboot-minimal.nix"
];
services.getty.autologinUser = lib.mkForce "root";
networking.hostName = "installer-${node.config.networking.hostName}";
boot.postBootCommands = ''
for x in $(cat /proc/cmdline); do
case "$x"; in
installer.image=*)
IMAGE="''${x#installer.image=}"
;;
installer.device=*)
DEVICE="''${x#installer.device=}"
;;
esac
done
${retry}/bin/retry \
--times 10 \
--delay 15 \
-- ${curl}/bin/curl "$IMAGE" --output "$DEVICE"
'';
system.stateVersion = node.config.system.nixos.release;
}
)
];
in
writeScript "pxe-installer" ''
#!${bash}/bin/bash
set -eu -o pipefail
${pixiecore}/bin/pixiecore boot \
"${installer.config.system.build.kernel}/bzImage" \
"${installer.config.system.build.netbootRamdisk}/initrd" \
--cmdline='${concatStringsSep " " [
"init=${installer.config.system.build.toplevel}/init"
"loglevel=4"
"console=tty0"
"console=ttyS1,115200n8"
"installer.image={{ ID \"${node.config.system.build.diskoImages}/main.raw\" }}"
"installer.device=${node.config.disko.devices.disk.main.device}"
]}'
''