From 1287160cdf7d95a0876e76ff3f8b90d6f84dadd0 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Wed, 17 Jul 2024 04:08:04 +0100 Subject: [PATCH] feat: reduced some complexity --- applications/dns/dns.nix | 52 +++++++++++----------------------------- 1 file changed, 14 insertions(+), 38 deletions(-) diff --git a/applications/dns/dns.nix b/applications/dns/dns.nix index 0202922..ec32461 100644 --- a/applications/dns/dns.nix +++ b/applications/dns/dns.nix @@ -230,46 +230,14 @@ records = config.skynet.records + /* + Need to "manually" grab it from each server. + Nix is laxy evalusted so if it does not need to open a file it wont. + This is to iterate through each server (node) and evaluate the dns records for that server. + */ ++ builtins.concatLists ( lib.attrsets.mapAttrsToList ( - key: value: let - details_server = value.config.services.skynet."${name}".server; - details_records = value.config.services.skynet."${name}".records; - in - if builtins.hasAttr "dns" value.config.services.skynet - then - ( - # got to handle habing a dns record for the dns serves themselves. - if details_server.enable - then - ( - if details_server.primary - then - details_records - ++ [ - { - domain = "skynet.ie"; - record = "ns1"; - r_type = "A"; - value = details_server.ip; - server = false; - } - ] - else - details_records - ++ [ - { - domain = "skynet.ie"; - record = "ns2"; - r_type = "A"; - value = details_server.ip; - server = false; - } - ] - ) - else details_records - ) - else [] + key: value: value.config.services.skynet."${name}".records ) nodes ); @@ -327,6 +295,14 @@ in { "ip daddr ${cfg.server.ip} udp dport 53 counter packets 0 bytes 0 accept" ]; + services.skynet.dns.records = [ + { + record = nameserver; + r_type = "A"; + value = config.services.skynet.host.ip; + } + ]; + services.bind.zones = lib.attrsets.mergeAttrsList ( # uses teh domains lsited in teh records (lib.lists.forEach domains (domain: (create_entry_zone domain)))