diff options
Diffstat (limited to 'modules/installer.nix')
-rw-r--r-- | modules/installer.nix | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/modules/installer.nix b/modules/installer.nix new file mode 100644 index 00000000..3e5c6d5b --- /dev/null +++ b/modules/installer.nix | |||
@@ -0,0 +1,56 @@ | |||
1 | { flake, config, lib, pkgs, ... }: | ||
2 | |||
3 | let | ||
4 | cfg = config.installer.links; | ||
5 | |||
6 | installerOutPath = { | ||
7 | "cd-dvd" = _: installerBuild: "${installerBuild.config.system.build.isoImage}/iso"; | ||
8 | "netboot" = {system, variant}: installerBuild: pkgs.runCommandLocal "${system}-${variant}" {} '' | ||
9 | mkdir $out | ||
10 | install -m 0444 -t $out \ | ||
11 | ${installerBuild.config.system.build.netbootRamdisk}/initrd \ | ||
12 | ${installerBuild.config.system.build.kernel}/${config.system.boot.loader.kernelFile} \ | ||
13 | ${installerBuild.config.system.build.netbootIpxeScript}/netboot.ipxe \ | ||
14 | ${pkgs.ipxe.override { | ||
15 | additionalTargets = { | ||
16 | "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; | ||
17 | }; | ||
18 | additionalOptions = [ | ||
19 | "NSLOOKUP_CMD" | ||
20 | "PING_CMD" | ||
21 | "CONSOLE_CMD" | ||
22 | ]; | ||
23 | embedScript = pkgs.writeText "netboot.ipxe" '' | ||
24 | #!ipxe | ||
25 | |||
26 | chain netboot.ipxe | ||
27 | ''; | ||
28 | }}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} | ||
29 | ''; | ||
30 | }; | ||
31 | in { | ||
32 | options = { | ||
33 | installer.links = lib.mkOption { | ||
34 | type = lib.types.listOf (lib.types.submodule { | ||
35 | options = { | ||
36 | system = lib.mkOption { | ||
37 | type = lib.types.str; | ||
38 | }; | ||
39 | variant = lib.mkOption { | ||
40 | type = lib.types.str; | ||
41 | }; | ||
42 | }; | ||
43 | }); | ||
44 | default = []; | ||
45 | }; | ||
46 | }; | ||
47 | |||
48 | config = lib.mkIf (cfg != []) { | ||
49 | systemd.tmpfiles.rules = map (installer'@{system, variant}: | ||
50 | let | ||
51 | installer = "${system}-${variant}"; | ||
52 | installerBuild = builtins.addErrorContext "while evaluating installer-${installer}" flake.nixosConfigurations.${"installer-${installer}"}; | ||
53 | in "L+ /run/installer-${installer} - - - - ${installerOutPath.${variant} installer' installerBuild}" | ||
54 | ) cfg; | ||
55 | }; | ||
56 | } | ||