machines/nix/modules/nixos/infrastructure/provisioning/default.nix
Kaare Hoff Skovgaard fbed2265dd
All checks were successful
/ dev-shell (push) Successful in 18s
/ terraform-providers (push) Successful in 11s
/ rust-packages (push) Successful in 23s
/ check (push) Successful in 1m29s
Begin getting unifi/openstack setup working
Now I can create an instance, get NixOS on it, with
working IPv6 connectivity
2025-07-08 16:33:18 +02:00

76 lines
2 KiB
Nix

{
config,
lib,
inputs,
pkgs,
...
}:
let
cfg = config.khscodes.infrastructure.provisioning;
provisioning = {
modules = lib.mkOption {
type = lib.types.listOf lib.types.anything;
description = "Modules used to bring up the needed resources";
default = [ ];
};
secretsSource = lib.mkOption {
type = lib.types.enum [
"vault"
"bitwarden"
];
description = "Where to get the secrets for the provisioning from";
default = "vault";
};
endpoints = lib.mkOption {
type = lib.types.listOf (
lib.types.enum [
"openstack"
"aws"
"unifi"
"hcloud"
"cloudflare"
]
);
description = "Needed endpoints to be used during provisioning";
default = [ ];
};
};
in
{
options.khscodes.infrastructure.provisioning = {
pre = provisioning;
post = provisioning;
preConfig = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = "The generated config for the pre provisioning, if any was specified";
};
preImageUsername = lib.mkOption {
type = lib.types.str;
description = "The username for the image being deployed before being swapped for NixOS";
default = "root";
};
postConfig = lib.mkOption {
type = lib.types.nullOr lib.types.path;
description = "The generated config for the post provisioning, if any was specified";
};
};
config = {
khscodes.infrastructure.provisioning.preConfig =
if lib.lists.length cfg.pre.modules > 0 then
inputs.terranix.lib.terranixConfiguration {
system = pkgs.hostPlatform.system;
modules = cfg.pre.modules;
}
else
null;
khscodes.infrastructure.provisioning.postConfig =
if lib.lists.length cfg.post.modules > 0 then
inputs.terranix.lib.terranixConfiguration {
system = pkgs.hostPlatform.system;
modules = cfg.post.modules;
}
else
null;
};
}