mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
make-disk-image: add useVirtualDevices option
This commit is contained in:
2 files changed
+30
-14
No files matched your search
+21
-14
@@ -55,26 +55,29 @@ let
|
||||
customQemu = cfg.qemu;
|
||||
}
|
||||
);
|
||||
|
||||
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
|
||||
systemToInstall = extendModules {
|
||||
virtualDevicesModule = {
|
||||
disko.devices = lib.mkForce cleanedConfig.disko.devices;
|
||||
boot.loader.grub.devices = lib.mkForce cleanedConfig.boot.loader.grub.devices;
|
||||
};
|
||||
system = 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;
|
||||
}
|
||||
];
|
||||
};
|
||||
systemToInstallNative =
|
||||
cleanedSystem = system.extendModules {
|
||||
modules = [ virtualDevicesModule ];
|
||||
};
|
||||
systemNative =
|
||||
if binfmt.systemsAreDifferent then
|
||||
extendModules {
|
||||
system.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;
|
||||
boot.kernelPackages = lib.mkDefault cfg.kernelPackages;
|
||||
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||
@@ -82,7 +85,10 @@ let
|
||||
];
|
||||
}
|
||||
else
|
||||
systemToInstall;
|
||||
system;
|
||||
cleanedSystemNative = systemNative.extendModules {
|
||||
modules = [ virtualDevicesModule ];
|
||||
};
|
||||
dependencies =
|
||||
with pkgs;
|
||||
[
|
||||
@@ -111,9 +117,6 @@ let
|
||||
install -m600 ${pkgs.OVMF.variables} efivars.fd
|
||||
'';
|
||||
|
||||
closureInfo = pkgs.closureInfo {
|
||||
rootPaths = [ systemToInstall.config.system.build.toplevel ];
|
||||
};
|
||||
partitioner = ''
|
||||
set -efux
|
||||
# running udev, stolen from stage-1.sh
|
||||
@@ -124,7 +127,7 @@ let
|
||||
ln -sfn /proc/self/fd/2 /dev/stderr
|
||||
mkdir -p /etc/udev
|
||||
mount -t efivarfs none /sys/firmware/efi/efivars
|
||||
ln -sfn ${systemToInstallNative.config.environment.etc."udev/rules.d".source} /etc/udev/rules.d
|
||||
ln -sfn ${cleanedSystemNative.config.environment.etc."udev/rules.d".source} /etc/udev/rules.d
|
||||
mkdir -p /dev/.mdadm
|
||||
${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon
|
||||
partprobe
|
||||
@@ -134,9 +137,13 @@ let
|
||||
${lib.optionalString diskoCfg.testMode ''
|
||||
export IN_DISKO_TEST=1
|
||||
''}
|
||||
${lib.getExe systemToInstallNative.config.system.build.destroyFormatMount} --yes-wipe-all-disks
|
||||
${lib.getExe cleanedSystemNative.config.system.build.destroyFormatMount} --yes-wipe-all-disks
|
||||
'';
|
||||
|
||||
systemToInstall = if cfg.useVirtualDevices then cleanedSystem else system;
|
||||
closureInfo = pkgs.closureInfo {
|
||||
rootPaths = [ systemToInstall.config.system.build.toplevel ];
|
||||
};
|
||||
installer = lib.optionalString cfg.copyNixStore ''
|
||||
${binfmtSetup}
|
||||
unset NIX_REMOTE
|
||||
|
||||
@@ -134,6 +134,15 @@ in
|
||||
description = "QEMU image format to use for the disk images";
|
||||
default = "raw";
|
||||
};
|
||||
|
||||
useVirtualDevices = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = ''
|
||||
Replace device names with ones usable in VMs. Ex: `/dev/vda`.
|
||||
Disable this if the disk image is for use on real hardware.
|
||||
'';
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
memSize = lib.mkOption {
|
||||
|
||||
Reference in new issue
Block a user