fix: auto-installer works fully offline
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user