1 { pkgs, lib, config, machines, ... }:
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) gnupg;
9 inherit (config.services) knot;
10 inherit (config.users) users;
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
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 ${machines.mermet.extraArgs.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 ${machines.mermet.extraArgs.ipv4}
84 @ A ${machines.mermet.extraArgs.ipv4}
85 mermet A ${machines.mermet.extraArgs.ipv4}
86 losurdo A ${machines.losurdo.extraArgs.ipv4}
87 autoconfig A ${machines.mermet.extraArgs.ipv4}
88 doc A ${machines.mermet.extraArgs.ipv4}
89 code A ${machines.mermet.extraArgs.ipv4}
90 git A ${machines.mermet.extraArgs.ipv4}
91 imap A ${machines.mermet.extraArgs.ipv4}
92 mail A ${machines.mermet.extraArgs.ipv4}
93 mails A ${machines.mermet.extraArgs.ipv4}
94 news A ${machines.mermet.extraArgs.ipv4}
95 public-inbox A ${machines.mermet.extraArgs.ipv4}
96 ns A ${machines.mermet.extraArgs.ipv4}
97 pop A ${machines.mermet.extraArgs.ipv4}
98 smtp A ${machines.mermet.extraArgs.ipv4}
99 submission A ${machines.mermet.extraArgs.ipv4}
100 www A ${machines.mermet.extraArgs.ipv4}
101 lemoutona5pattes A ${machines.mermet.extraArgs.ipv4}
102 covid19 A ${machines.mermet.extraArgs.ipv4}
103 openconcerto A ${machines.losurdo.extraArgs.ipv4}
104 croc A ${machines.mermet.extraArgs.ipv4}
105 xmpp A ${machines.losurdo.extraArgs.ipv4}
106 tmp A ${machines.losurdo.extraArgs.ipv4}
107 stun A ${machines.mermet.extraArgs.ipv4}
108 turn A ${machines.mermet.extraArgs.ipv4}
109 proxy65 A ${machines.losurdo.extraArgs.ipv4}
111 ; SPF (Sender Policy Framework)
112 @ 3600 IN SPF "v=spf1 mx ip4:${machines.mermet.extraArgs.ipv4} -all"
113 @ 3600 IN TXT "v=spf1 mx ip4:${machines.mermet.extraArgs.ipv4} -all"
119 _git._tcp.git 18000 IN SRV 0 0 9418 git
120 _stun._udp 18000 IN SRV 0 5 3478 stun
121 _xmpp-client._tcp 18000 IN SRV 0 5 5222 xmpp
122 _xmpp-server._tcp 18000 IN SRV 0 5 5269 xmpp
123 _xmpp-server._tcp.salons 18000 IN SRV 0 5 5269 xmpp
125 ; CAA (Certificate Authority Authorization)
126 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
127 @ CAA 128 issue "letsencrypt.org"
130 users.groups.keys.members = [ users.knot.name ];
132 keyFiles = [ gnupg.secrets."knot/tsig/${domain}/acme.conf".path ];
134 security.gnupg.secrets."knot/tsig/${domain}/acme.conf" = {
135 # Generated with: keymgr -t acme_${domainID}
136 user = users.knot.name;
138 systemd.services.knot = {
139 after = [ gnupg.secrets."knot/tsig/${domain}/acme.conf".service ];
140 wants = [ gnupg.secrets."knot/tsig/${domain}/acme.conf".service ];
142 /* Useless since the zone is public
143 services.unbound.extraConfig = ''
145 name: "sourcephile.fr"
146 stub-addr: 127.0.0.1@5353