fix: auto-installer works fully offline
All checks were successful
CI / Format Check (push) Successful in 2s
CI / Flake Check (push) Successful in 1m35s
CI / Evaluate Key Configurations (nix-builder) (push) Successful in 10s
CI / Evaluate Key Configurations (nix-desktop1) (push) Successful in 12s
CI / Evaluate Key Configurations (nix-laptop1) (push) Successful in 8s
CI / Evaluate Artifacts (installer-iso-nix-laptop1) (push) Successful in 17s
CI / Evaluate Artifacts (lxc-nix-builder) (push) Successful in 11s

chore: run nix fmt

refactor: change usage of targetSystem to targetSystemBuild.toplevel

chore: run nix fmt

refactor: change usage of targetSystem to targetSystemBuild.toplevel
This commit is contained in:
UGA Innovation Factory
2026-01-05 15:40:05 -05:00
parent f68c63590b
commit 3f1801fd84
3 changed files with 33 additions and 46 deletions

View File

@@ -18,14 +18,8 @@ let
hostName:
let
targetConfig = self.nixosConfigurations.${hostName}.config;
targetSystem = targetConfig.system.build.toplevel;
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;
@@ -33,9 +27,8 @@ let
inherit
inputs
hostName
targetSystem
targetSystemBuild
diskoScript
closureExport
;
hostPlatform = system;
};

View File

@@ -1,7 +1,6 @@
# 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), `diskoScript` (the partitioning script),
# and `closureExport` (the pre-built NAR archive) to be passed as arguments.
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
{
config,
lib,
@@ -9,30 +8,30 @@
inputs,
hostName,
hostPlatform,
targetSystem,
targetSystemBuild,
diskoScript,
closureExport,
...
}:
{
# Ensure the entire system closure and all dependencies are included in the ISO
environment.systemPackages = [
pkgs.git
pkgs.bashInteractive
pkgs.curl
targetSystem
];
# Explicitly include the system closure in the ISO image to prevent any need to build or fetch
isoImage.contents = [
{
source = targetSystem;
target = "/system";
}
targetSystemBuild.toplevel
];
nixpkgs.hostPlatform = hostPlatform;
nix.settings.experimental-features = "nix-command flakes";
system.extraDependencies = with targetSystemBuild; [
toplevel
etc
bootStage2
];
isoImage.storeContents = [ targetSystemBuild.toplevel ];
systemd.services.auto-install = {
description = "Automatic NixOS install for ${hostName}";
after = [
@@ -55,17 +54,12 @@
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..."
# 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 ">>> Setting up NixOS..."
nixos-install \
--system ${targetSystemBuild.toplevel} \
--no-root-passwd \
--no-channel-copy \
--substituters ""
echo ">>> Done. Rebooting."
systemctl reboot