From 023b491d89055db8bee4f2f1d3682a44b9f6e6eb Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Thu, 30 May 2024 13:25:52 +0100 Subject: [PATCH] feat: standardise dns to using ``services.skynet."${name}";`` format --- applications/bitwarden/vaultwarden.nix | 2 +- applications/dns.nix | 91 +++++++++---------- applications/email.nix | 2 +- applications/games.nix | 2 +- applications/games/minecraft.nix | 2 +- applications/gitlab.nix | 2 +- applications/grafana.nix | 2 +- applications/ldap/backend.nix | 2 +- applications/ldap/server.nix | 2 +- applications/nextcloud.nix | 2 +- applications/nix_cache/nix_cache.nix | 2 +- applications/open_governance/keyserver.nix | 2 +- .../open_governance/open_governance.nix | 2 +- applications/skynet.ie.nix | 2 +- applications/skynet_users.nix | 2 +- applications/ulfm.nix | 2 +- machines/agentjones.nix | 2 +- machines/cadie.nix | 2 +- machines/calculon.nix | 2 +- machines/earth.nix | 2 +- machines/galatea.nix | 2 +- machines/gir.nix | 2 +- machines/glados.nix | 2 +- machines/kitt.nix | 2 +- machines/marvin.nix | 2 +- machines/neuromancer.nix | 2 +- machines/optimus.nix | 2 +- machines/retired/ash.nix | 2 +- machines/skynet.nix | 2 +- machines/vendetta.nix | 2 +- machines/vigil.nix | 2 +- machines/wheatly.nix | 2 +- 32 files changed, 76 insertions(+), 77 deletions(-) diff --git a/applications/bitwarden/vaultwarden.nix b/applications/bitwarden/vaultwarden.nix index 3e0c84e..1ae912c 100644 --- a/applications/bitwarden/vaultwarden.nix +++ b/applications/bitwarden/vaultwarden.nix @@ -39,7 +39,7 @@ in { domain ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = domain_sub; r_type = "CNAME"; diff --git a/applications/dns.nix b/applications/dns.nix index 6b7bc6b..5af8b46 100644 --- a/applications/dns.nix +++ b/applications/dns.nix @@ -5,7 +5,8 @@ nodes, ... }: let - cfg = config.skynet_dns; + name = "dns"; + cfg = config.services.skynet."${name}"; # reads that date to a string (will need to be fixed in 2038) current_date = lib.readFile "${pkgs.runCommand "timestamp" {} "echo -n `date +%s` > $out"}"; @@ -245,10 +246,10 @@ ++ builtins.concatLists ( lib.attrsets.mapAttrsToList ( key: value: let - details_server = value.config.skynet_dns.server; - details_records = value.config.skynet_dns.records; + details_server = value.config.services.skynet."${name}".server; + details_records = value.config.services.skynet."${name}".records; in - if builtins.hasAttr "skynet_dns" value.config + if builtins.hasAttr "dns" value.config.services.skynet then ( # got to handle habing a dns record for the dns serves themselves. @@ -294,51 +295,49 @@ in { ../config/dns.nix ]; - options = { - skynet_dns = { - server = { - enable = lib.mkEnableOption { - default = false; - description = "Skynet DNS server"; - type = lib.types.bool; - }; - - primary = lib.mkOption { - type = lib.types.bool; - default = false; - }; - - ip = lib.mkOption { - type = lib.types.str; - description = '' - ip of this server - ''; - }; + options.services.skynet."${name}" = { + server = { + enable = lib.mkEnableOption { + default = false; + description = "Skynet DNS server"; + type = lib.types.bool; }; - # mirrorred in ../config/dns.nix - records = lib.mkOption { - description = "Records, sorted based on therir type"; - type = with lib.types; - listOf (submodule { - options = { - record = lib.mkOption { - type = str; - }; - r_type = lib.mkOption { - type = enum ["A" "CNAME" "TXT" "PTR" "SRV" "MX"]; - }; - value = lib.mkOption { - type = str; - }; - server = lib.mkOption { - description = "Core record for a server"; - type = bool; - default = false; - }; + primary = lib.mkOption { + type = lib.types.bool; + default = false; + }; + + ip = lib.mkOption { + type = lib.types.str; + description = '' + ip of this server + ''; + }; + }; + + # mirrorred in ../config/dns.nix + records = lib.mkOption { + description = "Records, sorted based on therir type"; + type = with lib.types; + listOf (submodule { + options = { + record = lib.mkOption { + type = str; }; - }); - }; + r_type = lib.mkOption { + type = enum ["A" "CNAME" "TXT" "PTR" "SRV" "MX"]; + }; + value = lib.mkOption { + type = str; + }; + server = lib.mkOption { + description = "Core record for a server"; + type = bool; + default = false; + }; + }; + }); }; }; diff --git a/applications/email.nix b/applications/email.nix index 82e9e7f..8831d14 100644 --- a/applications/email.nix +++ b/applications/email.nix @@ -285,7 +285,7 @@ in { }; # set up dns record for it - skynet_dns.records = [ + services.skynet.dns.records = [ # basic one { record = "mail"; diff --git a/applications/games.nix b/applications/games.nix index 1c35588..f112ed1 100644 --- a/applications/games.nix +++ b/applications/games.nix @@ -46,7 +46,7 @@ in { }; config = mkIf cfg.enable { - skynet_dns.records = [ + services.skynet.dns.records = [ # need a base domain { record = cfg.domain.sub; diff --git a/applications/games/minecraft.nix b/applications/games/minecraft.nix index 5d51620..3f64108 100644 --- a/applications/games/minecraft.nix +++ b/applications/games/minecraft.nix @@ -62,7 +62,7 @@ in { "*.${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ # the minecraft (web) config server { record = "config.${cfg.domain.sub}"; diff --git a/applications/gitlab.nix b/applications/gitlab.nix index ebb2dd7..fc15cd0 100644 --- a/applications/gitlab.nix +++ b/applications/gitlab.nix @@ -106,7 +106,7 @@ in { ]; # using https://nixos.org/manual/nixos/stable/index.html#module-services-gitlab as a guide - skynet_dns.records = [ + services.skynet.dns.records = [ { record = cfg.domain.sub; r_type = "A"; diff --git a/applications/grafana.nix b/applications/grafana.nix index be8e948..11efcfe 100644 --- a/applications/grafana.nix +++ b/applications/grafana.nix @@ -37,7 +37,7 @@ in { }; config = mkIf cfg.enable { - skynet_dns.records = [ + services.skynet.dns.records = [ { record = "${name}"; r_type = "CNAME"; diff --git a/applications/ldap/backend.nix b/applications/ldap/backend.nix index 929404e..c5630f4 100644 --- a/applications/ldap/backend.nix +++ b/applications/ldap/backend.nix @@ -60,7 +60,7 @@ in { "${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = cfg.domain.sub; r_type = "CNAME"; diff --git a/applications/ldap/server.nix b/applications/ldap/server.nix index 107c3f9..d531cae 100644 --- a/applications/ldap/server.nix +++ b/applications/ldap/server.nix @@ -83,7 +83,7 @@ in { domain ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = cfg.domain.sub; r_type = "CNAME"; diff --git a/applications/nextcloud.nix b/applications/nextcloud.nix index a915980..5ed9c9e 100644 --- a/applications/nextcloud.nix +++ b/applications/nextcloud.nix @@ -59,7 +59,7 @@ in { "onlyoffice.${domain}" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = cfg.domain.sub; r_type = "CNAME"; diff --git a/applications/nix_cache/nix_cache.nix b/applications/nix_cache/nix_cache.nix index 91a5ccb..fd6ae5f 100644 --- a/applications/nix_cache/nix_cache.nix +++ b/applications/nix_cache/nix_cache.nix @@ -44,7 +44,7 @@ in { "${name}.skynet.ie" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = "${name}"; r_type = "CNAME"; diff --git a/applications/open_governance/keyserver.nix b/applications/open_governance/keyserver.nix index be682d4..e86c314 100644 --- a/applications/open_governance/keyserver.nix +++ b/applications/open_governance/keyserver.nix @@ -33,7 +33,7 @@ in { "${name}.skynet.ie" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = "${name}"; r_type = "CNAME"; diff --git a/applications/open_governance/open_governance.nix b/applications/open_governance/open_governance.nix index 263488c..dab1a8d 100644 --- a/applications/open_governance/open_governance.nix +++ b/applications/open_governance/open_governance.nix @@ -35,7 +35,7 @@ in { "${name}.skynet.ie" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = "${name}"; r_type = "CNAME"; diff --git a/applications/skynet.ie.nix b/applications/skynet.ie.nix index 9b64594..6e7c542 100644 --- a/applications/skynet.ie.nix +++ b/applications/skynet.ie.nix @@ -33,7 +33,7 @@ in { "renew.skynet.ie" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ # means root domain, so skynet.ie { record = "@"; diff --git a/applications/skynet_users.nix b/applications/skynet_users.nix index ac9112f..1b37c36 100644 --- a/applications/skynet_users.nix +++ b/applications/skynet_users.nix @@ -43,7 +43,7 @@ in { "*.users.skynet.ie" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = "users"; r_type = "CNAME"; diff --git a/applications/ulfm.nix b/applications/ulfm.nix index 36329f9..18e0ddd 100644 --- a/applications/ulfm.nix +++ b/applications/ulfm.nix @@ -57,7 +57,7 @@ in { "${cfg.domain.sub}.${cfg.domain.base}.${cfg.domain.tld}" ]; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = cfg.domain.sub; r_type = "CNAME"; diff --git a/machines/agentjones.nix b/machines/agentjones.nix index 161b001..0c36db7 100644 --- a/machines/agentjones.nix +++ b/machines/agentjones.nix @@ -31,7 +31,7 @@ in { tags = ["active-firewall"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/cadie.nix b/machines/cadie.nix index ae21be3..73c6bf6 100644 --- a/machines/cadie.nix +++ b/machines/cadie.nix @@ -31,7 +31,7 @@ in { tags = ["active"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/calculon.nix b/machines/calculon.nix index 0557968..556b605 100644 --- a/machines/calculon.nix +++ b/machines/calculon.nix @@ -39,7 +39,7 @@ in { }; # it has two network devices so two - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/earth.nix b/machines/earth.nix index a6915be..16dd17c 100644 --- a/machines/earth.nix +++ b/machines/earth.nix @@ -32,7 +32,7 @@ in { }; # it has two network devices so two - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/galatea.nix b/machines/galatea.nix index f82217c..e2c2574 100644 --- a/machines/galatea.nix +++ b/machines/galatea.nix @@ -32,7 +32,7 @@ in { tags = ["active"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/gir.nix b/machines/gir.nix index ebb17e2..eaf1d17 100644 --- a/machines/gir.nix +++ b/machines/gir.nix @@ -33,7 +33,7 @@ in { }; # add this server to dns - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/glados.nix b/machines/glados.nix index d1e7d2c..0b9a530 100644 --- a/machines/glados.nix +++ b/machines/glados.nix @@ -32,7 +32,7 @@ in { tags = ["active-gitlab"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/kitt.nix b/machines/kitt.nix index f036fe0..b5c6c5e 100644 --- a/machines/kitt.nix +++ b/machines/kitt.nix @@ -39,7 +39,7 @@ in { }; # add this server to dns - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/marvin.nix b/machines/marvin.nix index 1c4f57b..1f16c70 100644 --- a/machines/marvin.nix +++ b/machines/marvin.nix @@ -49,7 +49,7 @@ in { sudo_groups = groups; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/neuromancer.nix b/machines/neuromancer.nix index 660f618..4dc819f 100644 --- a/machines/neuromancer.nix +++ b/machines/neuromancer.nix @@ -44,7 +44,7 @@ in { tags = ["active-core"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/optimus.nix b/machines/optimus.nix index 095c55c..c5290cb 100644 --- a/machines/optimus.nix +++ b/machines/optimus.nix @@ -32,7 +32,7 @@ in { tags = ["active"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/retired/ash.nix b/machines/retired/ash.nix index ca2384b..b16fc39 100644 --- a/machines/retired/ash.nix +++ b/machines/retired/ash.nix @@ -39,7 +39,7 @@ in { "ip daddr ${ip_pub} udp dport 51820 counter packets 0 bytes 0 accept" ]; - skynet_dns.records = { + services.skynet.dns.records = { external = [ "${name} A ${ip_pub}" ]; diff --git a/machines/skynet.nix b/machines/skynet.nix index 4acaf6f..4cd0f05 100644 --- a/machines/skynet.nix +++ b/machines/skynet.nix @@ -35,7 +35,7 @@ in { tags = ["active-ext"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A"; diff --git a/machines/vendetta.nix b/machines/vendetta.nix index 73effa3..0305baf 100644 --- a/machines/vendetta.nix +++ b/machines/vendetta.nix @@ -52,7 +52,7 @@ in { }; }; - skynet_dns = { + services.skynet.dns = { server = { enable = true; # primary dns server (ns1) diff --git a/machines/vigil.nix b/machines/vigil.nix index e3c811c..0bda7ad 100644 --- a/machines/vigil.nix +++ b/machines/vigil.nix @@ -36,7 +36,7 @@ in { }; }; - skynet_dns = { + services.skynet.dns = { server = { enable = true; # secondary dns server (ns2) diff --git a/machines/wheatly.nix b/machines/wheatly.nix index 02eabce..6b16cbc 100644 --- a/machines/wheatly.nix +++ b/machines/wheatly.nix @@ -31,7 +31,7 @@ in { tags = ["active-gitlab"]; }; - skynet_dns.records = [ + services.skynet.dns.records = [ { record = name; r_type = "A";