1 {pkgs, lib, config, ...}:
3 let inherit (builtins.extraBuiltins) pass git;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config) networking;
6 inherit (config.services) nsd rspamd;
7 # Use the Git commit time of the ${zone}.nix file to set the serial number.
8 # WARNING: the ${zone}.nix must be committed into Git for this to work.
9 serial = zone: toString (git ./. [ "log" "-1" "--format=%ct" "--" (zone + ".nix") ]);
11 serial = file: lib.removeSuffix "\n" (readFile
12 (pkgs.runCommand "zone-serial"
13 { buildInputs = [ pkgs.git ];
14 buildDepends = [ (./. + file) ];
15 preferLocalBuild = true;
16 allowSubstitutes = false;
19 ${pkgs.git}/bin/git log -1 --format="%ct" -- ${file} >$out
22 # FIXME: make dedicated config options
23 #ipv4 = (elemAt networking.interfaces.enp1s0.ipv4.addresses 0).address;
24 ipv4 = "80.67.180.129";
25 #ipv6 = (elemAt networking.interfaces.enp1s0.ipv6.addresses 0).address;
26 sourcephileZone = domain: ''
29 ${networking.hostName} A ${ipv4}
41 ; SPF (Sender Policy Framework)
42 @ 3600 IN SPF "v=spf1 mx ip4:${ipv4} -all"
43 @ 3600 IN TXT "v=spf1 mx ip4:${ipv4} -all"
49 _git._tcp.git 18000 IN SRV 0 0 9418 git
53 + lib.optionalString rspamd.dkim.enable
55 (selector: sel: sel.dns)
56 rspamd.dkim.domains."${domain}".selectors)
62 # NOTE: cannot use networking.domain as attr key: infinite recursion.
64 # DOC: https://docs.gandi.net/en/domain_names/advanced_users/secondary_nameserver.html
65 provideXFR = [ "217.70.177.40 NOKEY" ];
66 notify = [ "217.70.177.40 NOKEY" ];
68 $ORIGIN ${networking.domainBase}.fr.
71 ; SOA (Start Of Authority)
73 ${serial networking.domainBase} ; Serial number
77 1d ; TTL (Time To Live) minimum
84 + sourcephileZone "${networking.domainBase}.fr";