fix: work on making the installer work offline

fix: ensure system closure is installed for derivations needed by the installer

fix: build closure in build-step instead of on iso
This commit is contained in:
UGA Innovation Factory
2026-01-05 11:58:38 -05:00
parent c2b5e4eafe
commit 0b353a3ec8
5 changed files with 42 additions and 4 deletions

View File

@@ -20,6 +20,12 @@ let
targetConfig = self.nixosConfigurations.${hostName}.config;
targetSystem = targetConfig.system.build.toplevel;
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
targetSystem
diskoScript
closureExport
;
hostPlatform = system;
};

View File

@@ -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,9 +11,11 @@
hostPlatform,
targetSystem,
diskoScript,
closureExport,
...
}:
{
# Ensure the entire system closure and all dependencies are included in the ISO
environment.systemPackages = [
pkgs.git
pkgs.bashInteractive
@@ -20,6 +23,18 @@
targetSystem
];
# Explicitly include the pre-built closure export and system in the ISO image
isoImage.contents = [
{
source = closureExport;
target = "/closure-export";
}
{
source = targetSystem;
target = "/system";
}
];
nixpkgs.hostPlatform = hostPlatform;
systemd.services.auto-install = {
@@ -44,8 +59,17 @@
echo ">>> Running disko script..."
${diskoScript}
echo ">>> Importing pre-built closure into target store..."
# Import the closure that was exported at build time
${pkgs.nix}/bin/nix-store --store /mnt --import < /closure-export/closure.nar > /dev/null
echo ">>> Running nixos-install..."
nixos-install --no-root-passwd --system ${targetSystem}
# Install with pre-built closure already imported (no evaluation or fetching needed)
${pkgs.nix}/bin/nixos-install \
--no-root-passwd \
--root /mnt \
--system ${targetSystem} \
--option substitute false
echo ">>> Done. Rebooting."
systemctl reboot