1 { pkgs, lib, config, servers, ... }:
3 domain = "autogeree.net";
4 domainID = lib.replaceStrings ["."] ["_"] domain;
5 inherit (builtins) attrValues;
6 inherit (builtins.extraBuiltins) git;
7 inherit (config) networking;
8 inherit (config.services) knot;
9 inherit (config.security) pass;
10 inherit (config.users) users groups;
11 # Use the Git commit time of the ${domain}.nix file to set the serial number.
12 # WARNING: the ${domain}.nix must be committed into Git for this to work.
13 # WARNING: this does not take other .nix into account, though they may contribute to the zone's data.
14 serial = domain: toString (git ./. [ "log" "-1" "--format=%ct" "--" (domain + ".nix") ]);
17 services.knot.zones."${domain}" = {
20 - id: acl_localhost_acme_${domainID}
24 update-owner-match: equal
25 update-owner-name: [_acme-challenge.${domain}]
27 - id: acl_tsig_acme_${domainID}
28 address: ${servers.losurdo.ipv4}
32 update-owner-match: equal
33 update-owner-name: [_acme-challenge.${domain}]
39 serial-policy: increment
41 notify: secondary_gandi
42 notify: secondary_muarf
45 acl: acl_localhost_acme_${domainID}
46 acl: acl_tsig_acme_${domainID}
48 dnssec-policy: ed25519
50 # TODO: increase the TTL once things have settled down
55 ; SOA (Start Of Authority)
57 ${serial domain} ; Serial number
60 1000h ; Expire (1000h)
70 @ A ${servers.mermet.ipv4}
71 mermet A ${servers.mermet.ipv4}
72 autoconfig A ${servers.mermet.ipv4}
73 code A ${servers.mermet.ipv4}
74 git A ${servers.mermet.ipv4}
75 imap A ${servers.mermet.ipv4}
76 mail A ${servers.mermet.ipv4}
77 ns A ${servers.mermet.ipv4}
78 pop A ${servers.mermet.ipv4}
79 smtp A ${servers.mermet.ipv4}
80 submission A ${servers.mermet.ipv4}
81 www A ${servers.mermet.ipv4}
82 chomsky A 91.216.110.36
85 ; SPF (Sender Policy Framework)
86 @ 3600 IN SPF "v=spf1 mx ip4:${servers.mermet.ipv4} -all"
87 @ 3600 IN TXT "v=spf1 mx ip4:${servers.mermet.ipv4} -all"
93 _git._tcp.git 18000 IN SRV 0 0 9418 git
95 ; CAA (Certificate Authority Authorization)
96 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
97 @ CAA 128 issue "letsencrypt.org"
101 keyFiles = [ pass.secrets."knot/tsig/${domain}/acme.conf".path ];
103 security.pass.secrets."knot/tsig/${domain}/acme.conf" = {
104 # Generated with: keymgr -t acme_${domainID}
105 user = users.knot.name;
107 systemd.services.knot = {
108 after = [ pass.secrets."knot/tsig/${domain}/acme.conf".service ];
109 wants = [ pass.secrets."knot/tsig/${domain}/acme.conf".service ];
111 /* Useless since the zone is public
112 services.unbound.extraConfig = ''
114 name: "autogeree.net"
115 stub-addr: 127.0.0.1@5353