1 { pkgs, lib, config, inputs, hosts, info, ... }:
3 domain = "sourcephile.fr";
4 domainID = lib.replaceStrings [ "." ] [ "_" ] domain;
5 inherit (config) networking;
6 inherit (config.services) knot;
7 inherit (config.users) users groups;
9 # TODO: increase the TTL once things have settled down
14 ; SOA (Start Of Authority)
16 ${toString inputs.self.lastModified} ; Serial number
19 1000h ; Expire (1000h)
25 @ NS ${info.gandi.dns.secondary.ns.name}.
28 ns.whoami4 A ${hosts.mermet._module.args.ipv4}
31 @ A ${hosts.mermet._module.args.ipv4}
32 mermet A ${hosts.mermet._module.args.ipv4}
33 autoconfig A ${hosts.mermet._module.args.ipv4}
34 calibre A ${hosts.mermet._module.args.ipv4}
35 doc A ${hosts.mermet._module.args.ipv4}
36 git A ${hosts.mermet._module.args.ipv4}
37 imap A ${hosts.mermet._module.args.ipv4}
38 mail A ${hosts.mermet._module.args.ipv4}
39 mails A ${hosts.mermet._module.args.ipv4}
40 news A ${hosts.mermet._module.args.ipv4}
41 public-inbox A ${hosts.mermet._module.args.ipv4}
42 ns A ${hosts.mermet._module.args.ipv4}
43 pop A ${hosts.mermet._module.args.ipv4}
44 smtp A ${hosts.mermet._module.args.ipv4}
45 submission A ${hosts.mermet._module.args.ipv4}
46 www A ${hosts.mermet._module.args.ipv4}
47 lemoutona5pattes A ${hosts.mermet._module.args.ipv4}
48 croc A ${hosts.mermet._module.args.ipv4}
49 stun A ${hosts.mermet._module.args.ipv4}
50 turn A ${hosts.mermet._module.args.ipv4}
51 whoami A ${hosts.mermet._module.args.ipv4}
52 code A ${hosts.mermet._module.args.ipv4}
53 miniflux A ${hosts.mermet._module.args.ipv4}
55 ; CNAME (Canonical Name)
56 openconcerto CNAME losurdo
61 cryptpad CNAME losurdo
62 cryptpad-api CNAME losurdo
63 cryptpad-files CNAME losurdo
64 cryptpad-sandbox CNAME losurdo
67 nix-serve CNAME losurdo
68 nix-extracache CNAME losurdo
69 nix-localcache CNAME lan.losurdo
71 radicle-mermet CNAME mermet
73 radicle-explorer CNAME radicle
75 ; DMARC (Domain-based Message Authentication, Reporting and Conformance)
76 _dmarc 3600 IN TXT "v=DMARC1; p=none; pct=100; rua=mailto:root+dmarc+aggregate@sourcephile.fr; ruf=mailto:root+dmarc+forensic@sourcephile.fr"
78 ; SPF (Sender Policy Framework)
79 @ 3600 IN TXT "v=spf1 mx ip4:${hosts.mermet._module.args.ipv4} -all"
82 _git._tcp.git 18000 IN SRV 0 0 9418 git
83 _stun._udp 18000 IN SRV 0 5 3478 stun
84 _xmpp-client._tcp 18000 IN SRV 0 5 5222 xmpp
85 _xmpp-server._tcp 18000 IN SRV 0 5 5269 xmpp
86 _xmpp-server._tcp.salons 18000 IN SRV 0 5 5269 xmpp
87 _xmpps-client._tcp 18000 IN SRV 0 5 5223 xmpp
88 _xmpps-server._tcp 18000 IN SRV 0 5 5270 xmpp
89 _xmpps-server._tcp.salons 18000 IN SRV 0 5 5270 xmpp
91 ; CAA (Certificate Authority Authorization)
92 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
93 @ CAA 128 issue "letsencrypt.org; validationmethods=dns-01"
96 # accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/78014180
99 services.knot.settingsFreeform = {
100 remote.ns_iodine.address = "127.0.0.1@1053";
101 acl."acl_localhost_acme_${domainID}" = {
102 address = "127.0.0.1";
104 update-owner = "name";
105 update-owner-match = "equal";
106 update-owner-name = [ "_acme-challenge" ];
107 update-type = [ "TXT" ];
109 acl."acl_tsig_acme_${domainID}" = {
110 key = "acme_${domainID}";
112 update-owner = "name";
113 update-owner-match = "equal";
114 update-owner-name = [ "_acme-challenge" ];
115 update-type = [ "TXT" ];
117 acl."acl_tsig_losurdo_${domainID}" = {
118 key = "losurdo_${domainID}";
120 update-owner = "name";
121 update-owner-match = "equal";
122 update-owner-name = [ "losurdo" "lan.losurdo" ];
123 update-type = [ "A" "AAAA" ];
125 mod-dnsproxy.proxy_iodine = {
126 remote = "ns_iodine";
130 file = "${domain}.zone";
131 serial-policy = "increment";
132 semantic-checks = true;
138 "acl_localhost_acme_${domainID}"
139 "acl_tsig_acme_${domainID}"
140 "acl_tsig_losurdo_${domainID}"
142 dnssec-signing = true;
143 dnssec-policy = "rsa";
145 #zone."i.${domain}" = {
146 # module = "mod-dnsproxy/proxy_iodine";
148 zone."whoami4.${domain}" = {
149 module = "mod-whoami";
150 file = pkgs.writeText "whoami4.zone" ''
152 @ SOA ns root.${domain}. (
161 ns A ${hosts.mermet._module.args.ipv4}
167 "/run/credentials/knot.service/${domain}.acme.conf"
168 # Generated with: keymgr -t losurdo_${domainID}
169 "/run/credentials/knot.service/losurdo.conf"
172 systemd.services.knot = {
176 +${pkgs.coreutils}/bin/install -D -o ${users.knot.name} -g ${groups."knot".name} -m 700 \
177 ${pkgs.writeText "${domain}.zone" zoneData} \
178 /var/lib/knot/zones/${domain}.zone
181 LoadCredentialEncrypted = [
182 "${domain}.acme.conf:${./. + "/${domain}/acme.conf.cred"}"
183 "losurdo.conf:${./. + "/${domain}/losurdo.conf.cred"}"
187 networking.nftables.ruleset = ''
189 set output-net-knot-ipv4 { type ipv4_addr; elements = { ${info.gandi.dns.secondary.axfr.ipv4} }; }
190 set output-net-knot-ipv6 { type ipv6_addr; elements = { ${info.gandi.dns.secondary.axfr.ipv6} }; }
193 /* Useless since the zone is public
194 services.unbound.settings = {
197 stub-addr = "127.0.0.1@5353";