mirror of
https://github.com/nix-community/disko.git
synced 2026-12-04 06:53: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;
|
customQemu = cfg.qemu;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
cleanedConfig = diskoLib.testLib.prepareDiskoConfig config diskoLib.testLib.devices;
|
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 = [
|
modules = [
|
||||||
cfg.extraConfig
|
cfg.extraConfig
|
||||||
{
|
{
|
||||||
disko.testMode = true;
|
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
|
if binfmt.systemsAreDifferent then
|
||||||
extendModules {
|
system.extendModules {
|
||||||
modules = [
|
modules = [
|
||||||
cfg.extraConfig
|
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;
|
boot.kernelPackages = lib.mkDefault cfg.kernelPackages;
|
||||||
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.hostPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
nixpkgs.buildPlatform = lib.mkForce pkgs.stdenv.hostPlatform;
|
||||||
@@ -82,7 +85,10 @@ let
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
systemToInstall;
|
system;
|
||||||
|
cleanedSystemNative = systemNative.extendModules {
|
||||||
|
modules = [ virtualDevicesModule ];
|
||||||
|
};
|
||||||
dependencies =
|
dependencies =
|
||||||
with pkgs;
|
with pkgs;
|
||||||
[
|
[
|
||||||
@@ -111,9 +117,6 @@ let
|
|||||||
install -m600 ${pkgs.OVMF.variables} efivars.fd
|
install -m600 ${pkgs.OVMF.variables} efivars.fd
|
||||||
'';
|
'';
|
||||||
|
|
||||||
closureInfo = pkgs.closureInfo {
|
|
||||||
rootPaths = [ systemToInstall.config.system.build.toplevel ];
|
|
||||||
};
|
|
||||||
partitioner = ''
|
partitioner = ''
|
||||||
set -efux
|
set -efux
|
||||||
# running udev, stolen from stage-1.sh
|
# running udev, stolen from stage-1.sh
|
||||||
@@ -124,7 +127,7 @@ let
|
|||||||
ln -sfn /proc/self/fd/2 /dev/stderr
|
ln -sfn /proc/self/fd/2 /dev/stderr
|
||||||
mkdir -p /etc/udev
|
mkdir -p /etc/udev
|
||||||
mount -t efivarfs none /sys/firmware/efi/efivars
|
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
|
mkdir -p /dev/.mdadm
|
||||||
${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon
|
${pkgs.systemdMinimal}/lib/systemd/systemd-udevd --daemon
|
||||||
partprobe
|
partprobe
|
||||||
@@ -134,9 +137,13 @@ let
|
|||||||
${lib.optionalString diskoCfg.testMode ''
|
${lib.optionalString diskoCfg.testMode ''
|
||||||
export IN_DISKO_TEST=1
|
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 ''
|
installer = lib.optionalString cfg.copyNixStore ''
|
||||||
${binfmtSetup}
|
${binfmtSetup}
|
||||||
unset NIX_REMOTE
|
unset NIX_REMOTE
|
||||||
|
|||||||
@@ -134,6 +134,15 @@ in
|
|||||||
description = "QEMU image format to use for the disk images";
|
description = "QEMU image format to use for the disk images";
|
||||||
default = "raw";
|
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 {
|
memSize = lib.mkOption {
|
||||||
|
|||||||
Reference in new issue
Block a user