unname config (#585)

Reviewed-on: fediversity/fediversity#585
This commit is contained in:
Kiara Grouwstra 2025-11-14 11:06:19 +01:00
parent f1c8b35dd7
commit b6e1b5cba7

View file

@ -68,12 +68,14 @@ let
httpBackend = mkOption {
description = "environment variables to configure the TF HTTP back-end, see <https://developer.hashicorp.com/terraform/language/backend/http#configuration-variables>";
# type = types.attrsOf (types.either types.str types.int);
type = types.submodule (http-backend: {
type = types.submodule (
{ config, ... }:
{
options = {
value = mkOption {
readOnly = true;
default = lib.mapAttrs' (k: v: lib.nameValuePair "TF_HTTP_${lib.toUpper k}" (builtins.toString v)) {
inherit (http-backend.config)
inherit (config)
address
update_method
lock_address
@ -101,7 +103,7 @@ let
lock_address = mkOption {
description = "The address of the lock REST endpoint.";
type = str;
default = http-backend.config.address;
default = config.address;
};
lock_method = mkOption {
description = "The HTTP method to use when locking.";
@ -111,7 +113,7 @@ let
unlock_address = mkOption {
description = "The address of the unlock REST endpoint.";
type = str;
default = http-backend.config.address;
default = config.address;
};
unlock_method = mkOption {
description = "The HTTP method to use when unlocking.";
@ -149,7 +151,8 @@ let
default = 30;
};
};
});
}
);
};
host-ssh = mkOption {
description = "SSH connection info to connect to a single host.";
@ -182,7 +185,9 @@ in
{
ssh-host = mkOption {
description = "A deployment by SSH to update a single existing NixOS host.";
type = submodule (ssh-host: {
type = submodule (
{ config, ... }:
{
options = {
system = mkOption {
description = "The architecture of the system to deploy to.";
@ -212,7 +217,7 @@ in
readOnly = true;
default =
let
inherit (ssh-host.config)
inherit (config)
system
ssh
caller
@ -254,7 +259,8 @@ in
'';
};
};
});
}
);
};
nixops4 = mkOption {
description = "A NixOps4 NixOS deployment. For an example, see https://github.com/nixops4/nixops4-nixos/blob/main/example/deployment.nix.";
@ -262,7 +268,9 @@ in
};
tf-host = mkOption {
description = "A Terraform deployment by SSH to update a single existing NixOS host.";
type = submodule (tf-host: {
type = submodule (
{ config, ... }:
{
options = {
system = mkOption {
description = "The architecture of the system to deploy to.";
@ -291,7 +299,7 @@ in
readOnly = true;
default =
let
inherit (tf-host.config)
inherit (config)
system
ssh
caller
@ -331,7 +339,8 @@ in
};
};
};
});
}
);
};
tf-proxmox-template = mkOption {
description = ''
@ -340,7 +349,9 @@ in
(https://registry.terraform.io/providers/bpg/proxmox/latest/docs#environment-variables-summary)
with role `PVEDatastoreAdmin`.
'';
type = submodule (tf-host: {
type = submodule (
{ config, ... }:
{
options = {
system = mkOption {
description = "The architecture of the system to deploy to.";
@ -362,7 +373,7 @@ in
readOnly = true;
default =
let
inherit (tf-host.config)
inherit (config)
system
ssh
httpBackend
@ -374,7 +385,7 @@ in
;
machine = import ../nixos.nix {
inherit sources system;
configuration = tf-host.config.nixos-configuration;
configuration = config.nixos-configuration;
};
name = "fediversity-template";
@ -414,7 +425,8 @@ in
'';
};
};
});
}
);
};
tf-proxmox-vm = mkOption {
description = ''
@ -423,7 +435,9 @@ in
(https://registry.terraform.io/providers/bpg/proxmox/latest/docs#environment-variables-summary)
with roles `PVEVMAdmin PVEDatastoreAdmin PVESDNUser`.
'';
type = submodule (tf-host: {
type = submodule (
{ config, ... }:
{
options = {
system = mkOption {
description = "The architecture of the system to deploy to.";
@ -506,7 +520,7 @@ in
readOnly = true;
default =
let
inherit (tf-host.config)
inherit (config)
system
ssh
caller
@ -571,11 +585,14 @@ in
});
};
};
});
}
);
};
tf-netbox-store-ips = mkOption {
description = "Store a range of IPs in a Netbox instance.";
type = submodule (tf-netbox-store-ips: {
type = submodule (
{ config, ... }:
{
options = {
inherit httpBackend;
startAddress = mkOption {
@ -593,7 +610,7 @@ in
readOnly = true;
default =
let
inherit (tf-netbox-store-ips.config)
inherit (config)
httpBackend
startAddress
endAddress
@ -609,36 +626,34 @@ in
};
};
};
});
}
);
};
tf-netbox-get-ip = mkOption {
description = "Get an available IP from a Netbox instance.";
type = submodule (tf-netbox-get-ip: {
type = submodule (
{ config, ... }:
{
options = {
inherit httpBackend;
run = mkOption {
type = types.package;
readOnly = true;
default =
let
inherit (tf-netbox-get-ip.config)
httpBackend
;
in
tfApply {
inherit httpBackend;
default = tfApply {
inherit (config) httpBackend;
directory = "tf-netbox-get-ip";
environment = {
};
};
};
};
});
}
);
};
octodns-zone = mkOption {
description = "Manage DNS records.";
type = submodule (
octodns-zone:
{ config, ... }:
let
dns = pkgs.callPackage sources."dns.nix" { };
in
@ -715,14 +730,14 @@ in
};
configuration = mkOption {
type = submodule {
options = octodns-zone.config.providers.${octodns-zone.config.provider}.configuration;
options = config.providers.${config.provider}.configuration;
};
default = { };
};
package = mkOption {
type = types.package;
example = "The package of the OctoDNS provider to deploy to, see <https://search.nixos.org/packages?channel=unstable&query=octodns-providers>.";
default = pkgs.octodns-providers.${octodns-zone.config.provider};
default = pkgs.octodns-providers.${config.provider};
};
packages = mkOption {
type = types.listOf types.package;
@ -733,7 +748,7 @@ in
.withProviders
(_: [
pkgs.octodns-providers.bind
octodns-zone.config.package
config.package
])
)
];
@ -742,7 +757,7 @@ in
type = types.path;
default =
let
inherit (octodns-zone.config)
inherit (config)
domain
zone
providers
@ -762,7 +777,7 @@ in
{
inherit class;
}
// octodns-zone.config.configuration
// config.configuration
// (lib.genAttrs secrets (k: "env/${lib.toUpper "${provider}_${k}"}"));
config = {
file_extension = "";
@ -789,7 +804,7 @@ in
type = types.package;
default =
let
inherit (octodns-zone.config)
inherit (config)
packages
conf
provider
@ -805,7 +820,7 @@ in
type = types.package;
default =
let
inherit (octodns-zone.config)
inherit (config)
packages
conf
provider