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
72 ; DMARC (Domain-based Message Authentication, Reporting and Conformance)
73 _dmarc 3600 IN TXT "v=DMARC1; p=none; pct=100; rua=mailto:root+dmarc+aggregate@sourcephile.fr; ruf=mailto:root+dmarc+forensic@sourcephile.fr"
75 ; SPF (Sender Policy Framework)
76 @ 3600 IN TXT "v=spf1 mx ip4:${hosts.mermet._module.args.ipv4} -all"
79 _git._tcp.git 18000 IN SRV 0 0 9418 git
80 _stun._udp 18000 IN SRV 0 5 3478 stun
81 _xmpp-client._tcp 18000 IN SRV 0 5 5222 xmpp
82 _xmpp-server._tcp 18000 IN SRV 0 5 5269 xmpp
83 _xmpp-server._tcp.salons 18000 IN SRV 0 5 5269 xmpp
84 _xmpps-client._tcp 18000 IN SRV 0 5 5223 xmpp
85 _xmpps-server._tcp 18000 IN SRV 0 5 5270 xmpp
86 _xmpps-server._tcp.salons 18000 IN SRV 0 5 5270 xmpp
88 ; CAA (Certificate Authority Authorization)
89 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
90 @ CAA 128 issue "letsencrypt.org; validationmethods=dns-01"
93 # accounturi=https://acme-v02.api.letsencrypt.org/acme/acct/78014180
96 services.knot.settingsFreeform = {
97 remote.ns_iodine.address = "127.0.0.1@1053";
98 acl."acl_localhost_acme_${domainID}" = {
99 address = "127.0.0.1";
101 update-owner = "name";
102 update-owner-match = "equal";
103 update-owner-name = [ "_acme-challenge" ];
104 update-type = [ "TXT" ];
106 acl."acl_tsig_acme_${domainID}" = {
107 key = "acme_${domainID}";
109 update-owner = "name";
110 update-owner-match = "equal";
111 update-owner-name = [ "_acme-challenge" ];
112 update-type = [ "TXT" ];
114 acl."acl_tsig_losurdo_${domainID}" = {
115 key = "losurdo_${domainID}";
117 update-owner = "name";
118 update-owner-match = "equal";
119 update-owner-name = [ "losurdo" "lan.losurdo" ];
120 update-type = [ "A" "AAAA" ];
122 mod-dnsproxy.proxy_iodine = {
123 remote = "ns_iodine";
127 file = "${domain}.zone";
128 serial-policy = "increment";
129 semantic-checks = true;
135 "acl_localhost_acme_${domainID}"
136 "acl_tsig_acme_${domainID}"
137 "acl_tsig_losurdo_${domainID}"
139 dnssec-signing = true;
140 dnssec-policy = "rsa";
142 #zone."i.${domain}" = {
143 # module = "mod-dnsproxy/proxy_iodine";
145 zone."whoami4.${domain}" = {
146 module = "mod-whoami";
147 file = pkgs.writeText "whoami4.zone" ''
149 @ SOA ns root.${domain}. (
158 ns A ${hosts.mermet._module.args.ipv4}
164 "/run/credentials/knot.service/${domain}.acme.conf"
165 # Generated with: keymgr -t losurdo_${domainID}
166 "/run/credentials/knot.service/losurdo.conf"
169 systemd.services.knot = {
173 +${pkgs.coreutils}/bin/install -D -o ${users.knot.name} -g ${groups."knot".name} -m 700 \
174 ${pkgs.writeText "${domain}.zone" zoneData} \
175 /var/lib/knot/zones/${domain}.zone
178 LoadCredentialEncrypted = [
179 "${domain}.acme.conf:${./. + "/${domain}/acme.conf.cred"}"
180 "losurdo.conf:${./. + "/${domain}/losurdo.conf.cred"}"
184 networking.nftables.ruleset = ''
186 set output-net-knot-ipv4 { type ipv4_addr; elements = { ${info.gandi.dns.secondary.axfr.ipv4} }; }
187 set output-net-knot-ipv6 { type ipv6_addr; elements = { ${info.gandi.dns.secondary.axfr.ipv6} }; }
190 /* Useless since the zone is public
191 services.unbound.settings = {
194 stub-addr = "127.0.0.1@5353";