1 { pkgs, lib, config, servers, ... }:
3 domain = "sourcephile.fr";
4 domainID = lib.replaceStrings ["."] ["_"] domain;
5 inherit (builtins) attrValues;
6 inherit (builtins.extraBuiltins) pass git;
7 inherit (config) networking;
8 inherit (config.services) knot;
9 inherit (config.users) users groups;
10 # Use the Git commit time of the ${domain}.nix file to set the serial number.
11 # WARNING: the ${domain}.nix must be committed into Git for this to work.
12 # WARNING: this does not take other .nix into account, though they may contribute to the zone's data.
13 serial = domain: toString (git ./. [ "log" "-1" "--format=%ct" "--" (domain + ".nix") ]);
15 "${domain}/acme.conf" = "/var/lib/knot/tsig/${domain}/acme.conf";
19 install.shellHook = ''
20 # Generated with: keymgr -t acme_${domainID}
21 pass "servers/mermet/knot/${domain}/acme.conf" |
22 ssh "$target" install -D -m 0400 -o ${users."knot".name} -g root /dev/stdin \
23 ${includes."${domain}/acme.conf"}
26 keyFiles = attrValues includes;
28 services.knot.zones."${domain}" = {
31 - id: acl_localhost_acme_${domainID}
35 update-owner-match: equal
36 update-owner-name: [_acme-challenge.${domain}]
38 - id: acl_tsig_acme_${domainID}
39 address: ${servers.losurdo.ipv4}
43 update-owner-match: equal
44 update-owner-name: [_acme-challenge.${domain}]
50 serial-policy: increment
52 notify: secondary_gandi
54 acl: acl_localhost_acme_${domainID}
55 acl: acl_tsig_acme_${domainID}
58 - domain: whoami4.${domain}
60 file: "${pkgs.writeText "whoami4.zone" ''
62 @ SOA ns root.${domain}. (
63 ${serial domain} ; SERIAL
71 ns A ${servers.mermet.ipv4}
74 # TODO: increase the TTL once things have settled down
79 ; SOA (Start Of Authority)
81 ${serial domain} ; Serial number
84 1000h ; Expire (1000h)
92 ns.whoami4 A ${servers.mermet.ipv4}
95 @ A ${servers.mermet.ipv4}
96 mermet A ${servers.mermet.ipv4}
97 losurdo A ${servers.losurdo.ipv4}
98 autoconfig A ${servers.mermet.ipv4}
99 doc A ${servers.mermet.ipv4}
100 code A ${servers.mermet.ipv4}
101 git A ${servers.mermet.ipv4}
102 imap A ${servers.mermet.ipv4}
103 mail A ${servers.mermet.ipv4}
104 mails A ${servers.mermet.ipv4}
105 news A ${servers.mermet.ipv4}
106 public-inbox A ${servers.mermet.ipv4}
107 ns A ${servers.mermet.ipv4}
108 pop A ${servers.mermet.ipv4}
109 smtp A ${servers.mermet.ipv4}
110 submission A ${servers.mermet.ipv4}
111 www A ${servers.mermet.ipv4}
112 lemoutona5pattes A ${servers.mermet.ipv4}
113 covid19 A ${servers.mermet.ipv4}
114 openconcerto A ${servers.losurdo.ipv4}
116 ; SPF (Sender Policy Framework)
117 @ 3600 IN SPF "v=spf1 mx ip4:${servers.mermet.ipv4} -all"
118 @ 3600 IN TXT "v=spf1 mx ip4:${servers.mermet.ipv4} -all"
124 _git._tcp.git 18000 IN SRV 0 0 9418 git
126 ; CAA (Certificate Authority Authorization)
127 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
128 @ CAA 128 issue "letsencrypt.org"
131 /* Useless since the zone is public
132 services.unbound.extraConfig = ''
134 name: "sourcephile.fr"
135 stub-addr: 127.0.0.1@5353