1{
2 config,
3 extendModules,
4 lib,
5 ...
6}:
7let
8
9 inherit (lib)
10 mkOption
11 ;
12
13 vmVariant = extendModules {
14 modules = [ ./qemu-vm.nix ];
15 };
16
17 vmVariantWithBootLoader = vmVariant.extendModules {
18 modules = [
19 (
20 { config, ... }:
21 {
22 _file = "nixos/default.nix##vmWithBootLoader";
23 virtualisation.useBootLoader = true;
24 virtualisation.useEFIBoot =
25 config.boot.loader.systemd-boot.enable || config.boot.loader.efi.canTouchEfiVariables;
26 }
27 )
28 ];
29 };
30in
31{
32 options = {
33
34 virtualisation.vmVariant = mkOption {
35 description = ''
36 Machine configuration to be added for the vm script produced by `nixos-rebuild build-vm`.
37 '';
38 inherit (vmVariant) type;
39 default = { };
40 visible = "shallow";
41 };
42
43 virtualisation.vmVariantWithBootLoader = mkOption {
44 description = ''
45 Machine configuration to be added for the vm script produced by `nixos-rebuild build-vm-with-bootloader`.
46 '';
47 inherit (vmVariantWithBootLoader) type;
48 default = { };
49 visible = "shallow";
50 };
51
52 };
53
54 config = {
55
56 system.build = {
57 vm = lib.mkDefault config.virtualisation.vmVariant.system.build.vm;
58 vmWithBootLoader = lib.mkDefault config.virtualisation.vmVariantWithBootLoader.system.build.vm;
59 };
60
61 virtualisation.vmVariant = {
62 options = {
63 virtualisation.vmVariant = lib.mkOption {
64 apply = _: throw "virtualisation.vmVariant*.virtualisation.vmVariant is not supported";
65 };
66 virtualisation.vmVariantWithBootLoader = lib.mkOption {
67 apply =
68 _: throw "virtualisation.vmVariant*.virtualisation.vmVariantWithBootloader is not supported";
69 };
70 };
71 };
72
73 };
74
75 # uses extendModules
76 meta.buildDocsInSandbox = false;
77}