1 { pkgs, lib, config, ... }:
3 inherit (builtins.extraBuiltins) pass git;
4 inherit (pkgs.lib) unlinesAttrs types;
5 inherit (config) networking;
6 inherit (config.services) knot;
7 inherit (config) users;
8 # Use the Git commit time of the ${domain}.nix file to set the serial number.
9 # WARNING: the ${domain}.nix must be committed into Git for this to work.
10 # WARNING: this does not take other .nix into account, though they may contribute to the zone's data.
11 serial = domain: toString (git ./. [ "log" "-1" "--format=%ct" "--" (domain + ".nix") ]);
12 mermetIPv4 = "80.67.180.129";
13 domain = "autogeree.net";
16 systemd.services."acme-${domain}".after = [
19 security.acme.certs."${domain}" = {
20 email = "root+letsencrypt@${domain}";
24 group = users.groups.acme.name;
25 allowKeysForGroup = true;
27 dnsProvider = "rfc2136";
28 credentialsFile = pkgs.writeText "credentials" ''
29 RFC2136_NAMESERVER=127.0.0.1:5353
30 LEGO_EXPERIMENTAL_CNAME_SUPPORT=1
33 services.knot.zones."${domain}" = {
36 - id: acl_acme_challenge_autogeree_net
40 update-owner-match: equal
41 update-owner-name: [_acme-challenge.${domain}]
47 serial-policy: increment
49 notify: secondary_gandi
50 notify: secondary_muarf
53 acl: acl_acme_challenge_autogeree_net
55 dnssec-policy: ed25519
57 # TODO: increase the TTL once things have settled down
62 ; SOA (Start Of Authority)
64 ${serial domain} ; Serial number
67 1000h ; Expire (1000h)
78 mermet A ${mermetIPv4}
79 autoconfig A ${mermetIPv4}
87 submission A ${mermetIPv4}
89 chomsky A 91.216.110.36
92 ; SPF (Sender Policy Framework)
93 @ 3600 IN SPF "v=spf1 mx ip4:${mermetIPv4} -all"
94 @ 3600 IN TXT "v=spf1 mx ip4:${mermetIPv4} -all"
100 _git._tcp.git 18000 IN SRV 0 0 9418 git
102 ; CAA (Certificate Authority Authorization)
103 ; DOC: https://blog.qualys.com/ssllabs/2017/03/13/caa-mandated-by-cabrowser-forum
104 @ CAA 128 issue "letsencrypt.org"
107 /* Useless since the zone is public
108 services.unbound.extraConfig = ''
110 name: "autogeree.net"
111 stub-addr: 127.0.0.1@5353