1 { pkgs, lib, config, servers, ... }:
3 domain = "sourcephile.fr";
4 domainID = lib.replaceStrings ["."] ["_"] domain;
5 inherit (builtins) attrValues;
6 inherit (builtins.extraBuiltins) git;
7 inherit (config) networking;
8 inherit (config.security) pass;
9 inherit (config.services) knot;
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
43 acl: acl_localhost_acme_${domainID}
44 acl: acl_tsig_acme_${domainID}
47 - domain: whoami4.${domain}
49 file: "${pkgs.writeText "whoami4.zone" ''
51 @ SOA ns root.${domain}. (
52 ${serial domain} ; SERIAL
60 ns A ${servers.mermet.ipv4}
63 # TODO: increase the TTL once things have settled down
68 ; SOA (Start Of Authority)
70 ${serial domain} ; Serial number
73 1000h ; Expire (1000h)
81 ns.whoami4 A ${servers.mermet.ipv4}
84 @ A ${servers.mermet.ipv4}
85 mermet A ${servers.mermet.ipv4}
86 losurdo A ${servers.losurdo.ipv4}
87 autoconfig A ${servers.mermet.ipv4}
88 doc A ${servers.mermet.ipv4}
89 code A ${servers.mermet.ipv4}
90 git A ${servers.mermet.ipv4}
91 imap A ${servers.mermet.ipv4}
92 mail A ${servers.mermet.ipv4}
93 mails A ${servers.mermet.ipv4}
94 news A ${servers.mermet.ipv4}
95 public-inbox A ${servers.mermet.ipv4}
96 ns A ${servers.mermet.ipv4}
97 pop A ${servers.mermet.ipv4}
98 smtp A ${servers.mermet.ipv4}
99 submission A ${servers.mermet.ipv4}
100 www A ${servers.mermet.ipv4}
101 lemoutona5pattes A ${servers.mermet.ipv4}
102 covid19 A ${servers.mermet.ipv4}
103 openconcerto A ${servers.losurdo.ipv4}
105 ; SPF (Sender Policy Framework)
106 @ 3600 IN SPF "v=spf1 mx ip4:${servers.mermet.ipv4} -all"
107 @ 3600 IN TXT "v=spf1 mx ip4:${servers.mermet.ipv4} -all"
113 _git._tcp.git 18000 IN SRV 0 0 9418 git
115 ; CAA (Certificate Authority Authorization)
116 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
117 @ CAA 128 issue "letsencrypt.org"
121 keyFiles = [ pass.secrets."knot/tsig/${domain}/acme.conf".path ];
123 security.pass.secrets."knot/tsig/${domain}/acme.conf" = {
124 # Generated with: keymgr -t acme_${domainID}
125 user = users.knot.name;
127 systemd.services.knot = {
128 after = [ pass.secrets."knot/tsig/${domain}/acme.conf".service ];
129 wants = [ pass.secrets."knot/tsig/${domain}/acme.conf".service ];
131 /* Useless since the zone is public
132 services.unbound.extraConfig = ''
134 name: "sourcephile.fr"
135 stub-addr: 127.0.0.1@5353