{pkgs, lib, config, ...}: let inherit (builtins) toString toPath readFile; inherit (builtins.extraBuiltins) pass; inherit (pkgs.lib) unlinesAttrs; inherit (config) networking; inherit (config.services) nsd dkim; serial = zone: toString (builtins.extraBuiltins.git ./. [ "log" "-1" "--format=%ct" "--" (zone + ".nix") ]); /* serial = file: lib.removeSuffix "\n" (readFile (pkgs.runCommand "zone-serial" { buildInputs = [ pkgs.git ]; buildDepends = [ (toPath ./. + file) ]; preferLocalBuild = true; allowSubstitutes = false; } '' cd ${toPath ./.} ${pkgs.git}/bin/git log -1 --format="%ct" -- ${file} >$out '')); */ ipv4 = networking.zones.net.ipv4; plurasoftZone = domain: '' ; A (DNS -> IPv4) @ A ${ipv4} autoconfig A ${ipv4} git A ${ipv4} imap A ${ipv4} mail A ${ipv4} ns A ${ipv4} pop A ${ipv4} redmine A ${ipv4} smtp A ${ipv4} submission A ${ipv4} www A ${ipv4} ; SPF (Sender Policy Framework) @ 3600 IN SPF "v=spf1 mx ip4:${ipv4} -all" @ 3600 IN TXT "v=spf1 mx ip4:${ipv4} -all" ; MX (Mail eXchange) @ 180 MX 5 mail ; SRV (SeRVice) _git._tcp.git 18000 IN SRV 0 0 9418 git ; TXT (TeXT) '' + unlinesAttrs (selector: sel: sel.dns) dkim.domains."${domain}".selectors; in { config = { services.dkim.domains = let domain = rec { selector = "2019010101"; selectors = { "2019010101" = { key = pass "${networking.domainBase}/dkim/2019010101/key" + "\n"; dns = '' 2019010101._domainkey IN TXT ( "v=DKIM1; k=rsa; " "p=MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7EKzverbG+5JF+yFjH3MrxLyauiHyLqBbV/8LEMunoKXF8sqhBpQtAQXruLqsyUkxR/4CAyPMyzmcdrU43boMj9yFqLrg/kEz2RIvai9jXBqRoWRW1y7F0LbZmdtOTncuDSP8Zzo02XUzsOC4f/C3tEQHS5rchzfhU5FY1CeO6eBMV79qKBOvGMKahQTrrtU6olAAJxOhn6wRuwSf" "+m3on1OqiuXYYIgNHKdRhJ8gDwIm/3LEpYMD0gTgJiyclCLoLGHGtKZy1Wf9xV9/7V6fHE4JW5SDivwslVTL+KPXOlIpo5NDHpMxPYOcIg2K4Rj/j7jhavo+fG43q1LhwaPkEMQMbplgnjeMY8300odRiklTkMMpH0m35ZNeHQJSRpEtV8y5xUNxVaGzfqX5iStwV/mQ1KnZSe8ORTNq+eTTFnDk6zdUXjagcf0wO6QsSTeAz/G8CqOBbwmrU+q" "F8WbGAeRnhz51mH6fTTfsQ1nwjAiF4ou+eQGTkTMN23KkCKpuozJnxqx4DCEr6J1bL83fhXw7CgcfgKgTOk/HFJpeiGhqodw18r4DWBA6G57z9utm7Mr/9SoVnMq6iK9iEcbCllLR8Sz4viatLSRzhodbk7hfvXS3jmCFjILAjFmA7aMTemDMBDQhpAGF9F8sjFUbEJIZjKrWWtSTdO8DilDqN8CAwEAAQ==" ) ; ''; }; }; }; in { "${networking.domainBase}.fr" = domain; "plura.fr" = domain; "${networking.domainBase}.org" = domain; "${networking.domainBase}.net" = domain; "${networking.domainBase}.coop" = domain; }; services.nsd = { zones = { # NOTE: cannot use networking.domain as attr key: infinite recursion "plurasoft.fr" = { data = '' $ORIGIN ${networking.domainBase}.fr. $TTL 86400 ; SOA (Start Of Authority) @ SOA ns admin ( ${serial networking.domainBase} ; Serial number 1d ; Refresh 15m ; Retry 2592000 ; Expire 1d ; TTL (Time To Live) minimum ) ; NS (Name Server) @ NS ns ;@ NS ns6.gandi.net. '' + plurasoftZone "${networking.domainBase}.fr"; }; "plura.fr" = { data = '' $ORIGIN lessbug.gy. $TTL 86400 ; SOA (Start Of Authority) @ SOA ns admin ( ${serial "plurasoft"} ; Serial number 1d ; Refresh 15m ; Retry 2592000 ; Expire 1d ; TTL (Time To Live) minimum ) ; NS (Name Server) @ NS ns ;@ NS ns6.gandi.net. '' + plurasoftZone "plura.fr"; }; "plurasoft.org" = { data = '' $ORIGIN ${networking.domainBase}.org. $TTL 86400 ; SOA (Start Of Authority) @ SOA ns admin ( ${serial networking.domainBase} ; Serial number 1d ; Refresh 15m ; Retry 2592000 ; Expire 1d ; TTL (Time To Live) minimum ) ; NS (Name Server) @ NS ns ;@ NS ns6.gandi.net. '' + plurasoftZone "${networking.domainBase}.org"; }; "plurasoft.net" = { data = '' $ORIGIN ${networking.domainBase}.net. $TTL 86400 ; SOA (Start Of Authority) @ SOA ns admin ( ${serial networking.domainBase} ; Serial number 1d ; Refresh 15m ; Retry 2592000 ; Expire 1d ; TTL (Time To Live) minimum ) ; NS (Name Server) @ NS ns ;@ NS ns6.gandi.net. '' + plurasoftZone "${networking.domainBase}.net"; }; "plurasoft.coop" = { data = '' $ORIGIN ${networking.domainBase}.coop. $TTL 86400 ; SOA (Start Of Authority) @ SOA ns admin ( ${serial networking.domainBase} ; Serial number 1d ; Refresh 15m ; Retry 2592000 ; Expire 1d ; TTL (Time To Live) minimum ) ; NS (Name Server) @ NS ns ;@ NS ns6.gandi.net. '' + plurasoftZone "${networking.domainBase}.coop"; }; }; }; }; }