]> Git — Sourcephile - sourcephile-nix.git/blob - hosts/losurdo/acme/sourcephile.fr.nix
nix: update input secrets
[sourcephile-nix.git] / hosts / losurdo / acme / sourcephile.fr.nix
1 { pkgs, lib, config, hosts, ... }:
2 let
3 domain = "sourcephile.fr";
4 domainID = lib.replaceStrings ["."] ["_"] domain;
5 inherit (config.security) gnupg;
6 inherit (config.users) users groups;
7 in
8 {
9 networking.nftables.ruleset = ''
10 table inet filter {
11 # ACME DNS-01 challenge and Gandi DNS
12 set output-net-lego-ipv4 {
13 type ipv4_addr
14 elements = {
15 ${hosts.mermet._module.args.ipv4},
16 217.70.177.40
17 }
18 }
19 set output-net-lego-ipv6 {
20 type ipv6_addr
21 elements = { 2001:4b98:d:1::40 }
22 }
23 }
24 '';
25 security.acme.certs."${domain}" = {
26 email = "root+letsencrypt@${domain}";
27 extraDomainNames = [
28 "*.${domain}"
29 ];
30 group = groups.acme.name;
31 keyType = "rsa4096";
32 dnsProvider = "rfc2136";
33 # ns6.gandi.net takes roughly 5min to update
34 # hence lego's RFC2136_PROPAGATION_TIMEOUT=1000
35 #dnsPropagationCheck = false;
36 credentialsFile = gnupg.secrets."lego/${domain}/rfc2136".path;
37 };
38 security.gnupg.secrets."lego/${domain}/rfc2136" = {
39 pipe = ''
40 cat - ${pkgs.writeText "env" ''
41 RFC2136_NAMESERVER=ns.${domain}:53
42 RFC2136_TSIG_ALGORITHM=hmac-sha256.
43 RFC2136_TSIG_KEY=acme_${domainID}
44 RFC2136_PROPAGATION_TIMEOUT=1000
45 RFC2136_POLLING_INTERVAL=30
46 RFC2136_SEQUENCE_INTERVAL=30
47 RFC2136_DNS_TIMEOUT=1000
48 RFC2136_TTL=1
49 ''}
50 '';
51 };
52 systemd.services."acme-${domain}" = {
53 after = [
54 "unbound.service"
55 gnupg.secrets."lego/${domain}/rfc2136".service
56 ];
57 wants = [
58 "unbound.service"
59 gnupg.secrets."lego/${domain}/rfc2136".service
60 ];
61 };
62 }