diff --git a/installer/artifacts.nix b/installer/artifacts.nix index 3e835b6..31752cf 100644 --- a/installer/artifacts.nix +++ b/installer/artifacts.nix @@ -20,6 +20,12 @@ let targetConfig = self.nixosConfigurations.${hostName}.config; targetSystemBuild = targetConfig.system.build; diskoScript = targetConfig.system.build.diskoScript; + + # Build the closure export at build time (not runtime in ISO) + closureExport = pkgs.runCommand "closure-export-${hostName}" { } '' + mkdir -p $out + ${pkgs.nix}/bin/nix-store --export $(${pkgs.nix}/bin/nix-store -qR ${targetSystem}) > $out/closure.nar + ''; in nixpkgs.lib.nixosSystem { inherit system; @@ -29,6 +35,7 @@ let hostName targetSystemBuild diskoScript + closureExport ; hostPlatform = system; }; diff --git a/installer/auto-install.nix b/installer/auto-install.nix index 5f06984..67a8ef2 100644 --- a/installer/auto-install.nix +++ b/installer/auto-install.nix @@ -1,6 +1,7 @@ # This module defines a systemd service that automatically installs NixOS to the disk. # It is intended to be used in an installation ISO. -# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments. +# It expects `targetSystem` (the closure to install), `diskoScript` (the partitioning script), +# and `closureExport` (the pre-built NAR archive) to be passed as arguments. { config, lib, @@ -10,6 +11,7 @@ hostPlatform, targetSystemBuild, diskoScript, + closureExport, ... }: { @@ -21,8 +23,12 @@ targetSystemBuild.toplevel ]; - # Explicitly include the system closure in the ISO image to prevent any need to build or fetch + # Explicitly include the pre-built closure export and system in the ISO image isoImage.contents = [ + { + source = closureExport; + target = "/closure-export"; + } { source = targetSystem; target = "/system";