]> Git — Sourcephile - sourcephile-nix.git/blob - install/logical/friot/nsd/plurasoft.nix
update .lib/nixpkgs-plurasoft
[sourcephile-nix.git] / install / logical / friot / nsd / plurasoft.nix
1 {pkgs, lib, config, ...}:
2 let inherit (builtins) toString toPath readFile;
3 inherit (builtins.extraBuiltins) pass;
4 inherit (pkgs.lib) unlinesAttrs;
5 inherit (config) networking;
6 inherit (config.services) nsd dkim;
7 serial = zone: toString (builtins.extraBuiltins.git ./. [ "log" "-1" "--format=%ct" "--" (zone + ".nix") ]);
8 /*
9 serial = file: lib.removeSuffix "\n" (readFile
10 (pkgs.runCommand "zone-serial"
11 { buildInputs = [ pkgs.git ];
12 buildDepends = [ (toPath ./. + file) ];
13 preferLocalBuild = true;
14 allowSubstitutes = false;
15 } ''
16 cd ${toPath ./.}
17 ${pkgs.git}/bin/git log -1 --format="%ct" -- ${file} >$out
18 ''));
19 */
20 ipv4 = networking.zones.net.ipv4;
21 plurasoftZone = domain: ''
22 ; A (DNS -> IPv4)
23 @ A ${ipv4}
24 autoconfig A ${ipv4}
25 git A ${ipv4}
26 imap A ${ipv4}
27 mail A ${ipv4}
28 ns A ${ipv4}
29 pop A ${ipv4}
30 redmine A ${ipv4}
31 smtp A ${ipv4}
32 submission A ${ipv4}
33 www A ${ipv4}
34
35 ; SPF (Sender Policy Framework)
36 @ 3600 IN SPF "v=spf1 mx ip4:${ipv4} -all"
37 @ 3600 IN TXT "v=spf1 mx ip4:${ipv4} -all"
38
39 ; MX (Mail eXchange)
40 @ 180 MX 5 mail
41
42 ; SRV (SeRVice)
43 _git._tcp.git 18000 IN SRV 0 0 9418 git
44
45 ; TXT (TeXT)
46 ''
47 + unlinesAttrs
48 (selector: sel: sel.dns)
49 dkim.domains."${domain}".selectors;
50 in
51 {
52 config = {
53 services.dkim.domains =
54 let domain = rec {
55 selector = "2019010101";
56 selectors = {
57 "2019010101" = {
58 key = pass "${networking.domainBase}/dkim/2019010101/key" + "\n";
59 dns = ''
60 2019010101._domainkey IN TXT ( "v=DKIM1; k=rsa; "
61 "p=MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA7EKzverbG+5JF+yFjH3MrxLyauiHyLqBbV/8LEMunoKXF8sqhBpQtAQXruLqsyUkxR/4CAyPMyzmcdrU43boMj9yFqLrg/kEz2RIvai9jXBqRoWRW1y7F0LbZmdtOTncuDSP8Zzo02XUzsOC4f/C3tEQHS5rchzfhU5FY1CeO6eBMV79qKBOvGMKahQTrrtU6olAAJxOhn6wRuwSf"
62 "+m3on1OqiuXYYIgNHKdRhJ8gDwIm/3LEpYMD0gTgJiyclCLoLGHGtKZy1Wf9xV9/7V6fHE4JW5SDivwslVTL+KPXOlIpo5NDHpMxPYOcIg2K4Rj/j7jhavo+fG43q1LhwaPkEMQMbplgnjeMY8300odRiklTkMMpH0m35ZNeHQJSRpEtV8y5xUNxVaGzfqX5iStwV/mQ1KnZSe8ORTNq+eTTFnDk6zdUXjagcf0wO6QsSTeAz/G8CqOBbwmrU+q"
63 "F8WbGAeRnhz51mH6fTTfsQ1nwjAiF4ou+eQGTkTMN23KkCKpuozJnxqx4DCEr6J1bL83fhXw7CgcfgKgTOk/HFJpeiGhqodw18r4DWBA6G57z9utm7Mr/9SoVnMq6iK9iEcbCllLR8Sz4viatLSRzhodbk7hfvXS3jmCFjILAjFmA7aMTemDMBDQhpAGF9F8sjFUbEJIZjKrWWtSTdO8DilDqN8CAwEAAQ=="
64 ) ;
65 '';
66 };
67 };
68 }; in
69 {
70 "${networking.domainBase}.fr" = domain;
71 "plura.fr" = domain;
72 "${networking.domainBase}.org" = domain;
73 "${networking.domainBase}.net" = domain;
74 "${networking.domainBase}.coop" = domain;
75 };
76 services.nsd = {
77 zones = {
78 # NOTE: cannot use networking.domain as attr key: infinite recursion
79 "plurasoft.fr" = {
80 data = ''
81 $ORIGIN ${networking.domainBase}.fr.
82 $TTL 86400
83
84 ; SOA (Start Of Authority)
85 @ SOA ns admin (
86 ${serial networking.domainBase} ; Serial number
87 1d ; Refresh
88 15m ; Retry
89 2592000 ; Expire
90 1d ; TTL (Time To Live) minimum
91 )
92
93 ; NS (Name Server)
94 @ NS ns
95 ;@ NS ns6.gandi.net.
96 ''
97 + plurasoftZone "${networking.domainBase}.fr";
98 };
99 "plura.fr" = {
100 data = ''
101 $ORIGIN lessbug.gy.
102 $TTL 86400
103
104 ; SOA (Start Of Authority)
105 @ SOA ns admin (
106 ${serial "plurasoft"} ; Serial number
107 1d ; Refresh
108 15m ; Retry
109 2592000 ; Expire
110 1d ; TTL (Time To Live) minimum
111 )
112
113 ; NS (Name Server)
114 @ NS ns
115 ;@ NS ns6.gandi.net.
116 ''
117 + plurasoftZone "plura.fr";
118 };
119 "plurasoft.org" = {
120 data = ''
121 $ORIGIN ${networking.domainBase}.org.
122 $TTL 86400
123
124 ; SOA (Start Of Authority)
125 @ SOA ns admin (
126 ${serial networking.domainBase} ; Serial number
127 1d ; Refresh
128 15m ; Retry
129 2592000 ; Expire
130 1d ; TTL (Time To Live) minimum
131 )
132
133 ; NS (Name Server)
134 @ NS ns
135 ;@ NS ns6.gandi.net.
136 ''
137 + plurasoftZone "${networking.domainBase}.org";
138 };
139 "plurasoft.net" = {
140 data = ''
141 $ORIGIN ${networking.domainBase}.net.
142 $TTL 86400
143
144 ; SOA (Start Of Authority)
145 @ SOA ns admin (
146 ${serial networking.domainBase} ; Serial number
147 1d ; Refresh
148 15m ; Retry
149 2592000 ; Expire
150 1d ; TTL (Time To Live) minimum
151 )
152
153 ; NS (Name Server)
154 @ NS ns
155 ;@ NS ns6.gandi.net.
156 ''
157 + plurasoftZone "${networking.domainBase}.net";
158 };
159 "plurasoft.coop" = {
160 data = ''
161 $ORIGIN ${networking.domainBase}.coop.
162 $TTL 86400
163
164 ; SOA (Start Of Authority)
165 @ SOA ns admin (
166 ${serial networking.domainBase} ; Serial number
167 1d ; Refresh
168 15m ; Retry
169 2592000 ; Expire
170 1d ; TTL (Time To Live) minimum
171 )
172
173 ; NS (Name Server)
174 @ NS ns
175 ;@ NS ns6.gandi.net.
176 ''
177 + plurasoftZone "${networking.domainBase}.coop";
178 };
179 };
180 };
181 };
182 }