1 { pkgs, lib, config, machines, ... }:
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) gnupg;
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: ${machines.losurdo.extraArgs.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 ${machines.mermet.extraArgs.ipv4}
71 mermet A ${machines.mermet.extraArgs.ipv4}
72 autoconfig A ${machines.mermet.extraArgs.ipv4}
73 code A ${machines.mermet.extraArgs.ipv4}
74 git A ${machines.mermet.extraArgs.ipv4}
75 imap A ${machines.mermet.extraArgs.ipv4}
76 mail A ${machines.mermet.extraArgs.ipv4}
77 ns A ${machines.mermet.extraArgs.ipv4}
78 pop A ${machines.mermet.extraArgs.ipv4}
79 smtp A ${machines.mermet.extraArgs.ipv4}
80 submission A ${machines.mermet.extraArgs.ipv4}
81 www A ${machines.mermet.extraArgs.ipv4}
82 chomsky A 91.216.110.36
85 ; SPF (Sender Policy Framework)
86 @ 3600 IN SPF "v=spf1 mx ip4:${machines.mermet.extraArgs.ipv4} -all"
87 @ 3600 IN TXT "v=spf1 mx ip4:${machines.mermet.extraArgs.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"
100 users.users.knot.extraGroups = [ groups.keys.name ];
102 keyFiles = [ gnupg.secrets."knot/tsig/${domain}/acme.conf".path ];
104 security.gnupg.secrets."knot/tsig/${domain}/acme.conf" = {
105 # Generated with: keymgr -t acme_${domainID}
106 user = users.knot.name;
108 systemd.services.knot = {
109 after = [ gnupg.secrets."knot/tsig/${domain}/acme.conf".service ];
110 wants = [ gnupg.secrets."knot/tsig/${domain}/acme.conf".service ];
112 /* Useless since the zone is public
113 services.unbound.extraConfig = ''
115 name: "autogeree.net"
116 stub-addr: 127.0.0.1@5353