nixos: Move build-vm into virtualisation.vmVariant

... which is like a specialisation, but for nixos-rebuild build-vm
This commit is contained in:
Robert Hensing 2021-12-17 13:15:55 +01:00
parent 8fd49c116b
commit f72432aeb2
3 changed files with 49 additions and 20 deletions

View File

@ -9,24 +9,6 @@ let
modules = [ configuration ];
};
# This is for `nixos-rebuild build-vm'.
vm = eval.extendModules {
modules = [ ./modules/virtualisation/qemu-vm.nix ];
};
# This is for `nixos-rebuild build-vm-with-bootloader'.
vmWithBootLoader = vm.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
{
@ -34,7 +16,7 @@ in
system = eval.config.system.build.toplevel;
vm = vm.config.system.build.vm;
vm = eval.config.virtualisation.vmVariant.system.build.vm;
vmWithBootLoader = vmWithBootLoader.config.system.build.vm;
vmWithBootLoader = eval.config.virtualisation.vmVariantWithBootLoader.system.build.vm;
}

View File

@ -1179,6 +1179,7 @@
./tasks/powertop.nix
./testing/service-runner.nix
./virtualisation/anbox.nix
./virtualisation/build-vm.nix
./virtualisation/container-config.nix
./virtualisation/containerd.nix
./virtualisation/containers.nix

View File

@ -0,0 +1,46 @@
{ extendModules, lib, ... }:
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 {
description = ''
Machine configuration to be added for the vm script produced by <literal>nixos-rebuild build-vm</literal>.
'';
inherit (vmVariant) type;
default = {};
visible = "shallow";
};
virtualisation.vmVariantWithBootLoader = mkOption {
description = ''
Machine configuration to be added for the vm script produced by <literal>nixos-rebuild build-vm-with-bootloader</literal>.
'';
inherit (vmVariantWithBootLoader) type;
default = {};
visible = "shallow";
};
};
}