From e51159153b5fbe5c41caab41a7212df93c42d34b Mon Sep 17 00:00:00 2001 From: danjujan <44864658+danjujan@users.noreply.github.com> Date: Fri, 14 Feb 2025 15:33:03 +0700 Subject: [PATCH] make-disk-image: format natively --- lib/make-disk-image.nix | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/make-disk-image.nix b/lib/make-disk-image.nix index 7281a16..b4a0b7d 100644 --- a/lib/make-disk-image.nix +++ b/lib/make-disk-image.nix @@ -51,6 +51,18 @@ let } ]; }; + systemToInstallNative = if binfmt.systemsAreDifferent then extendModules { + modules = [ + cfg.extraConfig + { + disko.testMode = true; + disko.devices = lib.mkForce cleanedConfig.disko.devices; + boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices; + nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform; + } + ]; + } + else systemToInstall; dependencies = with pkgs; [ bash coreutils @@ -88,7 +100,7 @@ let ln -sfn /proc/self/fd/2 /dev/stderr mkdir -p /etc/udev mount -t efivarfs none /sys/firmware/efi/efivars - ln -sfn ${systemToInstall.config.system.build.etc}/etc/udev/rules.d /etc/udev/rules.d + ln -sfn ${systemToInstallNative.config.system.build.etc}/etc/udev/rules.d /etc/udev/rules.d mkdir -p /dev/.mdadm ${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon partprobe @@ -98,10 +110,11 @@ let ${lib.optionalString diskoCfg.testMode '' export IN_DISKO_TEST=1 ''} - ${lib.getExe systemToInstall.config.system.build.destroyFormatMount} --yes-wipe-all-disks + ${lib.getExe systemToInstallNative.config.system.build.destroyFormatMount} --yes-wipe-all-disks ''; installer = lib.optionalString cfg.copyNixStore '' + ${binfmtSetup} # populate nix db, so nixos-install doesn't complain export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix nix-store --load-db < "${closureInfo}/registration"