fix: build closure in build-step instead of on iso
This commit is contained in:
@@ -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,6 +11,7 @@
|
||||
hostPlatform,
|
||||
targetSystem,
|
||||
diskoScript,
|
||||
closureExport,
|
||||
...
|
||||
}:
|
||||
{
|
||||
@@ -21,8 +23,12 @@
|
||||
targetSystem
|
||||
];
|
||||
|
||||
# Explicitly include the system closure in the ISO image to prevent any need to build or fetch
|
||||
# Explicitly include the pre-built closure export and system in the ISO image
|
||||
isoImage.contents = [
|
||||
{
|
||||
source = closureExport;
|
||||
target = "/closure-export";
|
||||
}
|
||||
{
|
||||
source = targetSystem;
|
||||
target = "/system";
|
||||
@@ -53,14 +59,13 @@
|
||||
echo ">>> Running disko script..."
|
||||
${diskoScript}
|
||||
|
||||
echo ">>> Copying system closure to target..."
|
||||
# Copy the entire system closure without substitution
|
||||
nix-store --store /mnt --load-db < <(nix-store --dump-db)
|
||||
nix-copy-closure --to /mnt ${targetSystem} 2>/dev/null || true
|
||||
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 in store
|
||||
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} \
|
||||
|
||||
Reference in New Issue
Block a user