2021-12-17 13:34:30 +00:00
|
|
|
{ config, extendModules, lib, ... }:
|
2021-12-17 12:15:55 +00:00
|
|
|
let
|
|
|
|
|
|
|
|
inherit (lib)
|
|
|
|
mkOption
|
|
|
|
;
|
|
|
|
|
|
|
|
vmVariant = extendModules {
|
|
|
|
modules = [ ./qemu-vm.nix ];
|
|
|
|
};
|
|
|
|
|
|
|
|
vmVariantWithBootLoader = vmVariant.extendModules {
|
|
|
|
modules = [
|
|
|
|
({ config, ... }: {
|
|
|
|
_file = "nixos/default.nix##vmWithBootLoader";
|
|
|
|
virtualisation.useBootLoader = true;
|
|
|
|
virtualisation.useEFIBoot =
|
|
|
|
config.boot.loader.systemd-boot.enable ||
|
|
|
|
config.boot.loader.efi.canTouchEfiVariables;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
|
|
|
|
virtualisation.vmVariant = mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-20 10:32:04 +00:00
|
|
|
Machine configuration to be added for the vm script produced by `nixos-rebuild build-vm`.
|
2021-12-17 12:15:55 +00:00
|
|
|
'';
|
|
|
|
inherit (vmVariant) type;
|
|
|
|
default = {};
|
|
|
|
visible = "shallow";
|
|
|
|
};
|
|
|
|
|
|
|
|
virtualisation.vmVariantWithBootLoader = mkOption {
|
2024-04-13 12:54:15 +00:00
|
|
|
description = ''
|
2022-07-20 10:32:04 +00:00
|
|
|
Machine configuration to be added for the vm script produced by `nixos-rebuild build-vm-with-bootloader`.
|
2021-12-17 12:15:55 +00:00
|
|
|
'';
|
|
|
|
inherit (vmVariantWithBootLoader) type;
|
|
|
|
default = {};
|
|
|
|
visible = "shallow";
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2021-12-17 13:34:30 +00:00
|
|
|
|
|
|
|
config = {
|
|
|
|
|
|
|
|
system.build = {
|
|
|
|
vm = lib.mkDefault config.virtualisation.vmVariant.system.build.vm;
|
|
|
|
vmWithBootLoader = lib.mkDefault config.virtualisation.vmVariantWithBootLoader.system.build.vm;
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
2022-01-14 18:17:11 +00:00
|
|
|
|
|
|
|
# uses extendModules
|
|
|
|
meta.buildDocsInSandbox = false;
|
2021-12-17 12:15:55 +00:00
|
|
|
}
|