nix-config/modules/cluster/deployment-options.nix

80 lines
1.9 KiB
Nix

{ zentralwerk, config, lib, ... }:
# our custom options
{
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} ||
lib.filterAttrs (_: hosts6:
hosts6 ? ${config.networking.hostName}
) hosts6 != {}
) zentralwerk.lib.config.site.net
);
};
persistedShares = mkOption {
type = with types; listOf str;
default = [ "/etc" "/home" "/var" ];
};
storage = mkOption {
type = types.enum [ "fast" "big" ];
default = "fast";
description = ''
Unused for now
'';
};
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
'';
};
};
config = {
# HACK: Avoid conflicts when building a NixOS configuration on Hydra
boot.loader.grub.enable = false;
fileSystems."/" = lib.mkDefault {
device = "rootfs";
fsType = "tmpfs";
options = [ "size=50%,mode=0755" ];
};
};
}