From 43c9825e49d25fbd2c19abcdeb8f73aee8be2a4c Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 14 May 2025 10:50:27 +0200 Subject: ... --- modules/installer.nix | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 modules/installer.nix (limited to 'modules/installer.nix') 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 @@ +{ flake, config, lib, pkgs, ... }: + +let + cfg = config.installer.links; + + installerOutPath = { + "cd-dvd" = _: installerBuild: "${installerBuild.config.system.build.isoImage}/iso"; + "netboot" = {system, variant}: installerBuild: pkgs.runCommandLocal "${system}-${variant}" {} '' + mkdir $out + install -m 0444 -t $out \ + ${installerBuild.config.system.build.netbootRamdisk}/initrd \ + ${installerBuild.config.system.build.kernel}/${config.system.boot.loader.kernelFile} \ + ${installerBuild.config.system.build.netbootIpxeScript}/netboot.ipxe \ + ${pkgs.ipxe.override { + additionalTargets = { + "bin-i386-efi/ipxe.efi" = "i386-ipxe.efi"; + }; + additionalOptions = [ + "NSLOOKUP_CMD" + "PING_CMD" + "CONSOLE_CMD" + ]; + embedScript = pkgs.writeText "netboot.ipxe" '' + #!ipxe + + chain netboot.ipxe + ''; + }}/{ipxe.efi,i386-ipxe.efi,ipxe.lkrn} + ''; + }; +in { + options = { + installer.links = lib.mkOption { + type = lib.types.listOf (lib.types.submodule { + options = { + system = lib.mkOption { + type = lib.types.str; + }; + variant = lib.mkOption { + type = lib.types.str; + }; + }; + }); + default = []; + }; + }; + + config = lib.mkIf (cfg != []) { + systemd.tmpfiles.rules = map (installer'@{system, variant}: + let + installer = "${system}-${variant}"; + installerBuild = builtins.addErrorContext "while evaluating installer-${installer}" flake.nixosConfigurations.${"installer-${installer}"}; + in "L+ /run/installer-${installer} - - - - ${installerOutPath.${variant} installer' installerBuild}" + ) cfg; + }; +} -- cgit v1.2.3