From 0b353a3ec822526f8725d341d8336d8eb47f45f5 Mon Sep 17 00:00:00 2001 From: UGA Innovation Factory Date: Mon, 5 Jan 2026 11:58:38 -0500 Subject: [PATCH 1/2] 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 --- hosts/boot.nix | 7 ++++++- hosts/types/nix-zima.nix | 2 +- installer/artifacts.nix | 7 +++++++ installer/auto-install.nix | 28 ++++++++++++++++++++++++++-- inventory.nix | 2 ++ 5 files changed, 42 insertions(+), 4 deletions(-) diff --git a/hosts/boot.nix b/hosts/boot.nix index 73e8f6c..a186612 100644 --- a/hosts/boot.nix +++ b/hosts/boot.nix @@ -34,6 +34,11 @@ type = lib.types.str; description = "The main disk device to use for installation."; }; + useSwap = lib.mkOption { + type = lib.types.bool; + default = true; + description = "Whether to create and use a swap partition."; + }; swapSize = lib.mkOption { type = lib.types.str; description = "The size of the swap partition."; @@ -115,7 +120,7 @@ }; # Swap Partition (size configurable per host) - swap = { + swap = lib.mkIf config.athenix.host.filesystem.useSwap { name = "swap"; label = "swap"; size = config.athenix.host.filesystem.swapSize; diff --git a/hosts/types/nix-zima.nix b/hosts/types/nix-zima.nix index d065186..40a9cec 100644 --- a/hosts/types/nix-zima.nix +++ b/hosts/types/nix-zima.nix @@ -37,7 +37,7 @@ ]; # ========== Filesystem Configuration ========== - athenix.host.filesystem.swapSize = lib.mkDefault "0G"; + athenix.host.filesystem.useSwap = lib.mkDefault false; athenix.host.filesystem.device = lib.mkDefault "/dev/mmcblk0"; athenix.host.buildMethods = lib.mkDefault [ "installer-iso" ]; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; diff --git a/installer/artifacts.nix b/installer/artifacts.nix index 087b1d1..c862a21 100644 --- a/installer/artifacts.nix +++ b/installer/artifacts.nix @@ -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; }; diff --git a/installer/auto-install.nix b/installer/auto-install.nix index 0bfc6e2..63d0ef1 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,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 diff --git a/inventory.nix b/inventory.nix index edcbdc8..f292de7 100644 --- a/inventory.nix +++ b/inventory.nix @@ -139,6 +139,8 @@ }; }; + # ========== ZimaBoard Desktops ========== + # Creates: nix-zima1, nix-zima2, nix-zima3 nix-zima.devices = 3; # ========== Ephemeral/Netboot System ========== -- 2.39.5 From d3a1665c75ad58365c22923e0180e029cf7b5b1b Mon Sep 17 00:00:00 2001 From: UGA Innovation Factory Date: Mon, 5 Jan 2026 15:40:05 -0500 Subject: [PATCH 2/2] fix: auto-installer works fully offline --- flake.lock | 24 ++++++++++----------- installer/artifacts.nix | 11 ++-------- installer/auto-install.nix | 44 +++++++++++++------------------------- 3 files changed, 29 insertions(+), 50 deletions(-) diff --git a/flake.lock b/flake.lock index 6e45d94..f076fab 100644 --- a/flake.lock +++ b/flake.lock @@ -318,11 +318,11 @@ ] }, "locked": { - "lastModified": 1767024057, - "narHash": "sha256-B1aycRjMRvb6QOGbnqDhiDzZwMebj5jxZ5qyJzaKvpI=", + "lastModified": 1767619900, + "narHash": "sha256-KpoCBPvwHz3gAQtIUkohE2InRBFK3r0/FM6z5SPWfvM=", "owner": "nix-community", "repo": "home-manager", - "rev": "34578a2fdfce4257ce5f5baf6e7efbd4e4e252b1", + "rev": "6bd04da47cfb48dfd15eabf08364b78ad894f5b2", "type": "github" }, "original": { @@ -464,11 +464,11 @@ }, "nixos-hardware": { "locked": { - "lastModified": 1766568855, - "narHash": "sha256-UXVtN77D7pzKmzOotFTStgZBqpOcf8cO95FcupWp4Zo=", + "lastModified": 1767185284, + "narHash": "sha256-ljDBUDpD1Cg5n3mJI81Hz5qeZAwCGxon4kQW3Ho3+6Q=", "owner": "NixOS", "repo": "nixos-hardware", - "rev": "c5db9569ac9cc70929c268ac461f4003e3e5ca80", + "rev": "40b1a28dce561bea34858287fbb23052c3ee63fe", "type": "github" }, "original": { @@ -518,11 +518,11 @@ }, "nixpkgs-old-kernel": { "locked": { - "lastModified": 1766687554, - "narHash": "sha256-DegN7KD/EtFSKXf2jvqL6lvev6GlfAAatYBcRC8goEo=", + "lastModified": 1767051569, + "narHash": "sha256-0MnuWoN+n1UYaGBIpqpPs9I9ZHW4kynits4mrnh1Pk4=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "fd0ca39c92fdb4012ed8d60e1683c26fddadd136", + "rev": "40ee5e1944bebdd128f9fbada44faefddfde29bd", "type": "github" }, "original": { @@ -534,11 +534,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1766885793, - "narHash": "sha256-P6RVkrM9JLCW6xBjSwHfgTOQ1JwBUma5xe5LI8xAPC0=", + "lastModified": 1767480499, + "narHash": "sha256-8IQQUorUGiSmFaPnLSo2+T+rjHtiNWc+OAzeHck7N48=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "9ef261221d1e72399f2036786498d78c38185c46", + "rev": "30a3c519afcf3f99e2c6df3b359aec5692054d92", "type": "github" }, "original": { diff --git a/installer/artifacts.nix b/installer/artifacts.nix index c862a21..3e835b6 100644 --- a/installer/artifacts.nix +++ b/installer/artifacts.nix @@ -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; }; diff --git a/installer/auto-install.nix b/installer/auto-install.nix index 63d0ef1..3a3b792 100644 --- a/installer/auto-install.nix +++ b/installer/auto-install.nix @@ -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,34 +8,26 @@ 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 pre-built closure export and system in the ISO image - isoImage.contents = [ - { - source = closureExport; - target = "/closure-export"; - } - { - 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 = [ @@ -59,17 +50,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 -- 2.39.5