Move vm options to the vm variants
This commit is contained in:
parent
55e075e01b
commit
8bb98177cf
1 changed files with 34 additions and 24 deletions
|
@ -1,20 +1,28 @@
|
||||||
{ config, lib, options, pkgs, ... }: {
|
{ config, lib, options, pkgs, ... }: {
|
||||||
options = {
|
options =
|
||||||
|
let
|
||||||
|
vmVariantOptions = {
|
||||||
|
virtualisation = {
|
||||||
|
runAsRoot = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
sharedHostKeys = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
|
||||||
|
qemu.runInBackground = lib.mkOption {
|
||||||
|
type = lib.types.bool;
|
||||||
|
default = false;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in {
|
||||||
virtualisation = {
|
virtualisation = {
|
||||||
runAsRoot = lib.mkOption {
|
vmVariant = vmVariantOptions;
|
||||||
type = lib.types.bool;
|
vmVariantWithBootLoader = vmVariantOptions;
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
sharedHostKeys = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
|
|
||||||
qemu.runInBackground = lib.mkOption {
|
|
||||||
type = lib.types.bool;
|
|
||||||
default = false;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -25,23 +33,25 @@
|
||||||
vmVariant: {
|
vmVariant: {
|
||||||
boot.loader.efi.efiSysMountPoint = lib.mkVMOverride "/boot";
|
boot.loader.efi.efiSysMountPoint = lib.mkVMOverride "/boot";
|
||||||
|
|
||||||
virtualisation.sharedDirectories = lib.optionalAttrs (vmVariant.virtualisation.sharedHostKeys) {
|
virtualisation = {
|
||||||
hostKeys =
|
runAsRoot = lib.mkIf vmVariant.virtualisation.sharedHostKeys true;
|
||||||
let
|
|
||||||
path = "/etc/ssh";
|
sharedDirectories = lib.optionalAttrs (vmVariant.virtualisation.sharedHostKeys) {
|
||||||
in {
|
hostKeys =
|
||||||
source = path;
|
let
|
||||||
target = path;
|
path = "/etc/ssh";
|
||||||
|
in {
|
||||||
|
source = path;
|
||||||
|
target = path;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
virtualisation = config.virtualisation;
|
virtualisation = config.virtualisation;
|
||||||
in {
|
in {
|
||||||
|
|
||||||
vmVariant = extendVMConfig virtualisation.vmVariant;
|
vmVariant = extendVMConfig virtualisation.vmVariant;
|
||||||
vmVariantWithBootLoader = extendVMConfig virtualisation.vmVariantWithBootLoader;
|
vmVariantWithBootLoader = extendVMConfig virtualisation.vmVariantWithBootLoader;
|
||||||
runAsRoot = lib.mkIf config.virtualisation.sharedHostKeys true;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Replace native `qemu` with `remote-viewer`
|
# Replace native `qemu` with `remote-viewer`
|
||||||
|
|
Loading…
Reference in a new issue