1 {pkgs, lib, config, ...}:
2 let inherit (builtins) toString toPath readFile;
3 inherit (builtins.extraBuiltins) pass;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config) networking;
6 inherit (config.services) nsd dkim;
7 serial = zone: toString (builtins.extraBuiltins.git ./. [ "log" "-1" "--format=%ct" "--" (zone + ".nix") ]);
9 serial = file: lib.removeSuffix "\n" (readFile
10 (pkgs.runCommand "zone-serial"
11 { buildInputs = [ pkgs.git ];
12 buildDepends = [ (toPath ./. + file) ];
13 preferLocalBuild = true;
14 allowSubstitutes = false;
17 ${pkgs.git}/bin/git log -1 --format="%ct" -- ${file} >$out
20 ipv4 = networking.zones.net.ipv4;
21 commonsoftZone = tld: ''
35 ; SPF (Sender Policy Framework)
36 @ 3600 IN SPF "v=spf1 mx ip4:${ipv4} -all"
37 @ 3600 IN TXT "v=spf1 mx ip4:${ipv4} -all"
43 _git._tcp.git 18000 IN SRV 0 0 9418 git
48 (selector: sel: sel.dns)
49 dkim.domains."${networking.domainBase}.${tld}".selectors;
53 services.dkim.domains =
55 selector = "2019010101";
58 key = pass "${networking.domainBase}/dkim/2019010101/key" + "\n";
60 2019010101._domainkey IN TXT ( "v=DKIM1; k=rsa; "
61 "p=MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7EKzverbG+5JF+yFjH3MrxLyauiHyLqBbV/8LEMunoKXF8sqhBpQtAQXruLqsyUkxR/4CAyPMyzmcdrU43boMj9yFqLrg/kEz2RIvai9jXBqRoWRW1y7F0LbZmdtOTncuDSP8Zzo02XUzsOC4f/C3tEQHS5rchzfhU5FY1CeO6eBMV79qKBOvGMKahQTrrtU6olAAJxOhn6wRuwSf"
62 "+m3on1OqiuXYYIgNHKdRhJ8gDwIm/3LEpYMD0gTgJiyclCLoLGHGtKZy1Wf9xV9/7V6fHE4JW5SDivwslVTL+KPXOlIpo5NDHpMxPYOcIg2K4Rj/j7jhavo+fG43q1LhwaPkEMQMbplgnjeMY8300odRiklTkMMpH0m35ZNeHQJSRpEtV8y5xUNxVaGzfqX5iStwV/mQ1KnZSe8ORTNq+eTTFnDk6zdUXjagcf0wO6QsSTeAz/G8CqOBbwmrU+q"
63 "F8WbGAeRnhz51mH6fTTfsQ1nwjAiF4ou+eQGTkTMN23KkCKpuozJnxqx4DCEr6J1bL83fhXw7CgcfgKgTOk/HFJpeiGhqodw18r4DWBA6G57z9utm7Mr/9SoVnMq6iK9iEcbCllLR8Sz4viatLSRzhodbk7hfvXS3jmCFjILAjFmA7aMTemDMBDQhpAGF9F8sjFUbEJIZjKrWWtSTdO8DilDqN8CAwEAAQ=="
70 "${networking.domainBase}.org" = domain;
71 "${networking.domainBase}.net" = domain;
72 "${networking.domainBase}.coop" = domain;
76 # NOTE: cannot use networking.domain as attr key: infinite recursion
79 $ORIGIN ${networking.domainBase}.org.
82 ; SOA (Start Of Authority)
84 ${serial networking.domainBase} ; Serial number
88 1d ; TTL (Time To Live) minimum
95 + commonsoftZone "org";
99 $ORIGIN ${networking.domainBase}.coop.
102 ; SOA (Start Of Authority)
104 ${serial networking.domainBase} ; Serial number
108 1d ; TTL (Time To Live) minimum
114 '' + commonsoftZone "coop";
118 $ORIGIN ${networking.domainBase}.net.
121 ; SOA (Start Of Authority)
123 ${serial networking.domainBase} ; Serial number
127 1d ; TTL (Time To Live) minimum
133 '' + commonsoftZone "net";