modules/cluster/customization/options: move types into separate file so that options can be merged on extendModules

This commit is contained in:
Astro 2023-01-20 18:25:56 +01:00
parent ea8bf43313
commit 6ef686ff46
3 changed files with 43 additions and 23 deletions

View File

@ -29,7 +29,7 @@ let
in
{
imports = [ ./options.nix ];
imports = [ ./option-types.nix ];
microvm = {
inherit (config.deployment) mem vcpu hypervisor;

View File

@ -0,0 +1,42 @@
{ lib, ... }:
{
options.deployment = with lib; {
vcpu = mkOption {
type = types.int;
};
mem = mkOption {
type = types.int;
};
hypervisor = mkOption {
type = types.enum [
"qemu"
"cloud-hypervisor"
"firecracker"
"crosvm"
"kvmtool"
];
};
networks = mkOption {
type = with types; listOf str;
};
persistedShares = mkOption {
type = with types; listOf str;
};
extraShares = mkOption {
type = with types; listOf (submodule {
options = {
source = mkOption {
type = str;
};
mountPoint = mkOption {
type = str;
};
};
});
};
needForSpeed = mkOption {
type = types.bool;
};
};
}

View File

@ -3,25 +3,15 @@
{
options.deployment = with lib; {
vcpu = mkOption {
type = types.int;
default = 4;
};
mem = mkOption {
type = types.int;
default = 512;
};
hypervisor = mkOption {
type = types.enum [
"qemu"
"cloud-hypervisor"
"firecracker"
"crosvm"
"kvmtool"
];
default = "cloud-hypervisor";
};
networks = mkOption {
type = with types; listOf str;
default = builtins.attrNames (
lib.filterAttrs (_: { hosts4, hosts6, ... }:
hosts4 ? ${config.networking.hostName} ||
@ -32,27 +22,15 @@
);
};
persistedShares = mkOption {
type = with types; listOf str;
default = [ "/etc" "/home" "/var" ];
};
extraShares = mkOption {
type = with types; listOf (submodule {
options = {
source = mkOption {
type = str;
};
mountPoint = mkOption {
type = str;
};
};
});
default = [];
description = ''
Extra shares. THESE MUST BE AVAILABLE ON ALL MICROVM HOSTS!
'';
};
needForSpeed = mkOption {
type = types.bool;
default = false;
description = ''
Prefer deployment on Nomad clients with a higher c3d2.cpuSpeed