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
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:
24
flake.lock
generated
24
flake.lock
generated
@@ -318,11 +318,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1767024057,
|
"lastModified": 1767619900,
|
||||||
"narHash": "sha256-B1aycRjMRvb6QOGbnqDhiDzZwMebj5jxZ5qyJzaKvpI=",
|
"narHash": "sha256-KpoCBPvwHz3gAQtIUkohE2InRBFK3r0/FM6z5SPWfvM=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "home-manager",
|
"repo": "home-manager",
|
||||||
"rev": "34578a2fdfce4257ce5f5baf6e7efbd4e4e252b1",
|
"rev": "6bd04da47cfb48dfd15eabf08364b78ad894f5b2",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -464,11 +464,11 @@
|
|||||||
},
|
},
|
||||||
"nixos-hardware": {
|
"nixos-hardware": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1766568855,
|
"lastModified": 1767185284,
|
||||||
"narHash": "sha256-UXVtN77D7pzKmzOotFTStgZBqpOcf8cO95FcupWp4Zo=",
|
"narHash": "sha256-ljDBUDpD1Cg5n3mJI81Hz5qeZAwCGxon4kQW3Ho3+6Q=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixos-hardware",
|
"repo": "nixos-hardware",
|
||||||
"rev": "c5db9569ac9cc70929c268ac461f4003e3e5ca80",
|
"rev": "40b1a28dce561bea34858287fbb23052c3ee63fe",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -518,11 +518,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-old-kernel": {
|
"nixpkgs-old-kernel": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1766687554,
|
"lastModified": 1767051569,
|
||||||
"narHash": "sha256-DegN7KD/EtFSKXf2jvqL6lvev6GlfAAatYBcRC8goEo=",
|
"narHash": "sha256-0MnuWoN+n1UYaGBIpqpPs9I9ZHW4kynits4mrnh1Pk4=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "fd0ca39c92fdb4012ed8d60e1683c26fddadd136",
|
"rev": "40ee5e1944bebdd128f9fbada44faefddfde29bd",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@@ -534,11 +534,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs_2": {
|
"nixpkgs_2": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1766885793,
|
"lastModified": 1767480499,
|
||||||
"narHash": "sha256-P6RVkrM9JLCW6xBjSwHfgTOQ1JwBUma5xe5LI8xAPC0=",
|
"narHash": "sha256-8IQQUorUGiSmFaPnLSo2+T+rjHtiNWc+OAzeHck7N48=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "9ef261221d1e72399f2036786498d78c38185c46",
|
"rev": "30a3c519afcf3f99e2c6df3b359aec5692054d92",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@@ -18,14 +18,8 @@ let
|
|||||||
hostName:
|
hostName:
|
||||||
let
|
let
|
||||||
targetConfig = self.nixosConfigurations.${hostName}.config;
|
targetConfig = self.nixosConfigurations.${hostName}.config;
|
||||||
targetSystem = targetConfig.system.build.toplevel;
|
targetSystemBuild = targetConfig.system.build;
|
||||||
diskoScript = targetConfig.system.build.diskoScript;
|
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
|
in
|
||||||
nixpkgs.lib.nixosSystem {
|
nixpkgs.lib.nixosSystem {
|
||||||
inherit system;
|
inherit system;
|
||||||
@@ -33,9 +27,8 @@ let
|
|||||||
inherit
|
inherit
|
||||||
inputs
|
inputs
|
||||||
hostName
|
hostName
|
||||||
targetSystem
|
targetSystemBuild
|
||||||
diskoScript
|
diskoScript
|
||||||
closureExport
|
|
||||||
;
|
;
|
||||||
hostPlatform = system;
|
hostPlatform = system;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
# This module defines a systemd service that automatically installs NixOS to the disk.
|
# This module defines a systemd service that automatically installs NixOS to the disk.
|
||||||
# It is intended to be used in an installation ISO.
|
# It is intended to be used in an installation ISO.
|
||||||
# It expects `targetSystem` (the closure to install), `diskoScript` (the partitioning script),
|
# It expects `targetSystem` (the closure to install) and `diskoScript` (the partitioning script) to be passed as arguments.
|
||||||
# and `closureExport` (the pre-built NAR archive) to be passed as arguments.
|
|
||||||
{
|
{
|
||||||
config,
|
config,
|
||||||
lib,
|
lib,
|
||||||
@@ -9,30 +8,30 @@
|
|||||||
inputs,
|
inputs,
|
||||||
hostName,
|
hostName,
|
||||||
hostPlatform,
|
hostPlatform,
|
||||||
targetSystem,
|
targetSystemBuild,
|
||||||
diskoScript,
|
diskoScript,
|
||||||
closureExport,
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
{
|
{
|
||||||
# Ensure the entire system closure and all dependencies are included in the ISO
|
|
||||||
environment.systemPackages = [
|
environment.systemPackages = [
|
||||||
pkgs.git
|
pkgs.git
|
||||||
pkgs.bashInteractive
|
pkgs.bashInteractive
|
||||||
pkgs.curl
|
pkgs.curl
|
||||||
targetSystem
|
targetSystemBuild.toplevel
|
||||||
];
|
|
||||||
|
|
||||||
# Explicitly include the system closure in the ISO image to prevent any need to build or fetch
|
|
||||||
isoImage.contents = [
|
|
||||||
{
|
|
||||||
source = targetSystem;
|
|
||||||
target = "/system";
|
|
||||||
}
|
|
||||||
];
|
];
|
||||||
|
|
||||||
nixpkgs.hostPlatform = hostPlatform;
|
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 = {
|
systemd.services.auto-install = {
|
||||||
description = "Automatic NixOS install for ${hostName}";
|
description = "Automatic NixOS install for ${hostName}";
|
||||||
after = [
|
after = [
|
||||||
@@ -55,17 +54,12 @@
|
|||||||
echo ">>> Running disko script..."
|
echo ">>> Running disko script..."
|
||||||
${diskoScript}
|
${diskoScript}
|
||||||
|
|
||||||
echo ">>> Importing pre-built closure into target store..."
|
echo ">>> Setting up NixOS..."
|
||||||
# Import the closure that was exported at build time
|
nixos-install \
|
||||||
${pkgs.nix}/bin/nix-store --store /mnt --import < /closure-export/closure.nar > /dev/null
|
--system ${targetSystemBuild.toplevel} \
|
||||||
|
--no-root-passwd \
|
||||||
echo ">>> Running nixos-install..."
|
--no-channel-copy \
|
||||||
# Install with pre-built closure already imported (no evaluation or fetching needed)
|
--substituters ""
|
||||||
${pkgs.nix}/bin/nixos-install \
|
|
||||||
--no-root-passwd \
|
|
||||||
--root /mnt \
|
|
||||||
--system ${targetSystem} \
|
|
||||||
--option substitute false
|
|
||||||
|
|
||||||
echo ">>> Done. Rebooting."
|
echo ">>> Done. Rebooting."
|
||||||
systemctl reboot
|
systemctl reboot
|
||||||
|
|||||||
Reference in New Issue
Block a user