From 9618d87c672830c40e2bc49bbea6d20e38f45367 Mon Sep 17 00:00:00 2001 From: Brendan Golden Date: Sun, 21 May 2023 16:18:39 +0100 Subject: [PATCH] dns: parametrised the config --- applications/dns.nix | 100 ++++++++++++++++++++++--------------------- 1 file changed, 52 insertions(+), 48 deletions(-) diff --git a/applications/dns.nix b/applications/dns.nix index 9d5b05f..683f3b7 100644 --- a/applications/dns.nix +++ b/applications/dns.nix @@ -5,6 +5,57 @@ let # reads that date to a string (will need to be fixed in 2038) current_date = toString builtins.currentTime; + + + get_config_file = (domain: + '' + $TTL 60 ; 1 minute + ; hostmaster@${domain} is an email address that recieves stuff related to dns + @ IN SOA ${cfg.own.nameserver}.${domain}. hostmaster.${domain}. ( + ; Serial (YYYYMMDDCC) this has to be updated for each time the record is updated + ${current_date} + 600 ; Refresh (10 minutes) + 300 ; Retry (5 minutes) + 604800 ; Expire (1 week) + 3600 ; Minimum (1 hour) + ) + + @ NS ns1.${domain}. + @ NS ns2.${domain}. + ; @ stands for teh root domain so teh A record below is where ${domain} points to + @ A 193.1.99.76 + ;@ MX 5 ${domain}. + + ; can have multiple mailserves + ;@ MX 20 mail2.${domain}. + + + ; ------------------------------------------ + ; Server Names + ; ------------------------------------------ + + ; External addresses + ; ------------------------------------------ + ${lib.strings.concatMapStrings (x: x + "\n") cfg.records.external} + + + ; this is fixed for now + wintermute A 193.1.101.148 + + + ; internal addresses + ; ------------------------------------------ + ; May come back to this idea in teh future + ; agentjones.int A 172.20.20.1 + + + ; cname's + ; ------------------------------------------ + ${lib.strings.concatMapStrings (x: x + "\n") cfg.records.cname} + + '' + ); + in { options = { skynet_dns = { @@ -238,54 +289,7 @@ in { # The UNIX file mode bits mode = "0644"; - - text = - '' - $TTL 60 ; 1 minute - ; hostmaster@skynet.ie is an email address that recieves stuff related to dns - @ IN SOA ${cfg.own.nameserver}.skynet.ie. hostmaster.skynet.ie. ( - ; Serial (YYYYMMDDCC) this has to be updated for each time the record is updated - ${current_date} - 600 ; Refresh (10 minutes) - 300 ; Retry (5 minutes) - 604800 ; Expire (1 week) - 3600 ; Minimum (1 hour) - ) - - @ NS ns1.skynet.ie. - @ NS ns2.skynet.ie. - ; @ stands for teh root domain so teh A record below is where skynet.ie points to - @ A 193.1.99.76 - ;@ MX 5 mail.skynet.ie. - - ; can have multiple mailserves - ;@ MX 20 mail2.skynet.ie. - - - ; ------------------------------------------ - ; Server Names - ; ------------------------------------------ - - ; External addresses - ; ------------------------------------------ - ${lib.strings.concatMapStrings (x: x + "\n") cfg.records.external} - - - ; this is fixed for now - wintermute A 193.1.101.148 - - - ; internal addresses - ; ------------------------------------------ - ; May come back to this idea in teh future - ; agentjones.int A 172.20.20.1 - - - ; cname's - ; ------------------------------------------ - ${lib.strings.concatMapStrings (x: x + "\n") cfg.records.cname} - - ''; + text = get_config_file "skynet.ie"; }; }; };