make-disk-image: add testMode, copyNixStore & extraConfig params

This commit is contained in:
lassulus 2024-07-21 16:44:48 +02:00
parent 6208b31a73
commit c5e5018a04

View file

@ -5,6 +5,9 @@
, name ? "${nixosConfig.config.networking.hostName}-disko-images"
, extraPostVM ? nixosConfig.config.disko.extraPostVM
, checked ? false
, copyNixStore ? true
, testMode ? false
, extraConfig ? { }
}:
let
vmTools = pkgs.vmTools.override {
@ -15,10 +18,14 @@ let
};
cleanedConfig = diskoLib.testLib.prepareDiskoConfig nixosConfig.config diskoLib.testLib.devices;
systemToInstall = nixosConfig.extendModules {
modules = [{
modules = [
extraConfig
{
disko.testMode = true;
disko.devices = lib.mkForce cleanedConfig.disko.devices;
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
}];
}
];
};
dependencies = with pkgs; [
bash
@ -48,6 +55,7 @@ let
rootPaths = [ systemToInstall.config.system.build.toplevel ];
};
partitioner = ''
set -efux
# running udev, stolen from stage-1.sh
echo "running udev..."
ln -sfn /proc/self/fd /dev/fd
@ -63,10 +71,13 @@ let
udevadm trigger --action=add
udevadm settle
${lib.optionalString testMode ''
export IN_DISKO_TEST=1
''}
${systemToInstall.config.system.build.diskoScript}
'';
installer = ''
installer = lib.optionalString copyNixStore ''
# 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"