aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2020-01-10 00:01:45 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2020-01-10 00:01:45 +0100
commit619e4f46adc15e409122c4e0fa0e0a0b811bb32f (patch)
tree20f29e51aec4bcb1176b5d19b8d1f8358268b7ba
parentfd2af8fa50dc1a60d40a1aa3c4252d8eb3abf5b0 (diff)
downloadNix-619e4f46adc15e409122c4e0fa0e0a0b811bb32f.tar.gz
Nix-619e4f46adc15e409122c4e0fa0e0a0b811bb32f.tar.zst
Nix-619e4f46adc15e409122c4e0fa0e0a0b811bb32f.zip
Add backup MX
-rw-r--r--modules/private/certificates.nix4
-rw-r--r--modules/private/dns.nix23
-rw-r--r--modules/private/environment.nix115
-rw-r--r--modules/private/mail/default.nix8
-rw-r--r--modules/private/mail/milters.nix20
-rw-r--r--modules/private/mail/opensmtpd.nix6
-rw-r--r--modules/private/mail/postfix.nix15
-rw-r--r--modules/private/mail/relay.nix233
-rw-r--r--modules/private/monitoring/default.nix4
-rw-r--r--modules/private/monitoring/status.nix2
-rw-r--r--modules/private/system.nix2
-rw-r--r--modules/private/system/backup-2.nix21
-rw-r--r--modules/private/system/eldiron.nix7
-rw-r--r--modules/private/system/monitoring-1.nix5
-rw-r--r--modules/private/websites/tools/git/mantisbt.nix2
-rw-r--r--modules/private/websites/tools/mail/mta-sts.nix6
16 files changed, 373 insertions, 100 deletions
diff --git a/modules/private/certificates.nix b/modules/private/certificates.nix
index 9e60a09..2d24579 100644
--- a/modules/private/certificates.nix
+++ b/modules/private/certificates.nix
@@ -24,7 +24,7 @@
24 ''; 24 '';
25 services.nginx = { 25 services.nginx = {
26 recommendedTlsSettings = true; 26 recommendedTlsSettings = true;
27 virtualHosts = { "${config.hostEnv.FQDN}" = { useACMEHost = name; forceSSL = true; }; }; 27 virtualHosts = { "${config.hostEnv.fqdn}" = { useACMEHost = name; forceSSL = true; }; };
28 }; 28 };
29 services.websites.certs = config.myServices.certificates.certConfig; 29 services.websites.certs = config.myServices.certificates.certConfig;
30 myServices.databasesCerts = config.myServices.certificates.certConfig; 30 myServices.databasesCerts = config.myServices.certificates.certConfig;
@@ -34,7 +34,7 @@
34 34
35 security.acme.certs = { 35 security.acme.certs = {
36 "${name}" = config.myServices.certificates.certConfig // { 36 "${name}" = config.myServices.certificates.certConfig // {
37 domain = config.hostEnv.FQDN; 37 domain = config.hostEnv.fqdn;
38 }; 38 };
39 }; 39 };
40 40
diff --git a/modules/private/dns.nix b/modules/private/dns.nix
index fb90824..ebced42 100644
--- a/modules/private/dns.nix
+++ b/modules/private/dns.nix
@@ -50,6 +50,18 @@
50 '') 50 '')
51 cfg.zones } 51 cfg.zones }
52 ''; 52 '';
53 mxes = lib.attrsets.filterAttrs
54 (n: v: v.mx.enable)
55 config.myEnv.servers;
56 ip4mxes = builtins.concatStringsSep "\n" (lib.mapAttrsToList
57 (n: v: "${v.mx.subdomain} IN A ${v.ips.main.ip4}")
58 mxes);
59 ip6mxes = builtins.concatStringsSep "\n" (lib.mapAttrsToList
60 (n: v: builtins.concatStringsSep "\n" (map (i: "${v.mx.subdomain} IN AAAA ${i}") v.ips.main.ip6))
61 mxes);
62 mxmxes = n: conf: builtins.concatStringsSep "\n" (lib.mapAttrsToList
63 (_: v: "${n} IN MX ${v.mx.priority} ${v.mx.subdomain}.${conf.name}.")
64 mxes);
53 in lib.mkIf config.myServices.dns.enable { 65 in lib.mkIf config.myServices.dns.enable {
54 networking.firewall.allowedUDPPorts = [ 53 ]; 66 networking.firewall.allowedUDPPorts = [ 53 ];
55 networking.firewall.allowedTCPPorts = [ 53 ]; 67 networking.firewall.allowedTCPPorts = [ 53 ];
@@ -94,10 +106,8 @@
94 ${conf.entries} 106 ${conf.entries}
95 107
96 ${if lib.attrsets.hasAttr "withEmail" conf && lib.lists.length conf.withEmail > 0 then '' 108 ${if lib.attrsets.hasAttr "withEmail" conf && lib.lists.length conf.withEmail > 0 then ''
97 mx-1 IN A ${config.myEnv.servers.eldiron.ips.main.ip4} 109 ${ip4mxes}
98 mx-2 IN A ${config.myEnv.servers.immaeEu.ips.main.ip4} 110 ${ip6mxes}
99 ${builtins.concatStringsSep "\n" (map (i: "mx-1 IN AAAA ${i}") config.myEnv.servers.eldiron.ips.main.ip6)}
100 ${builtins.concatStringsSep "\n" (map (i: "mx-2 IN AAAA ${i}") config.myEnv.servers.immaeEu.ips.main.ip6)}
101 ${lib.concatStringsSep "\n\n" (map (e: 111 ${lib.concatStringsSep "\n\n" (map (e:
102 let 112 let
103 n = if e.domain == "" then "@" else "${e.domain} "; 113 n = if e.domain == "" then "@" else "${e.domain} ";
@@ -105,8 +115,7 @@
105 in 115 in
106 '' 116 ''
107 ; ------------------ mail: ${n} --------------------------- 117 ; ------------------ mail: ${n} ---------------------------
108 ${n} IN MX 10 mx-1.${conf.name}. 118 ${mxmxes n conf}
109 ${n} IN MX 20 mx-2.${conf.name}.
110 119
111 ; https://tools.ietf.org/html/rfc6186 120 ; https://tools.ietf.org/html/rfc6186
112 _submission._tcp${suffix} SRV 0 1 587 smtp.immae.eu. 121 _submission._tcp${suffix} SRV 0 1 587 smtp.immae.eu.
@@ -120,7 +129,7 @@
120 ; MTA-STS 129 ; MTA-STS
121 ; https://blog.delouw.ch/2018/12/16/using-mta-sts-to-enhance-email-transport-security-and-privacy/ 130 ; https://blog.delouw.ch/2018/12/16/using-mta-sts-to-enhance-email-transport-security-and-privacy/
122 ; https://support.google.com/a/answer/9261504 131 ; https://support.google.com/a/answer/9261504
123 _mta-sts${suffix} IN TXT "v=STSv1;id=20190630054629Z" 132 _mta-sts${suffix} IN TXT "v=STSv1;id=20200109150200Z"
124 _smtp._tls${suffix} IN TXT "v=TLSRPTv1;rua=mailto:postmaster+mta-sts@immae.eu" 133 _smtp._tls${suffix} IN TXT "v=TLSRPTv1;rua=mailto:postmaster+mta-sts@immae.eu"
125 mta-sts${suffix} IN A ${config.myEnv.servers.eldiron.ips.main.ip4} 134 mta-sts${suffix} IN A ${config.myEnv.servers.eldiron.ips.main.ip4}
126 ${builtins.concatStringsSep "\n" (map (i: "mta-sts${suffix} IN AAAA ${i}") config.myEnv.servers.eldiron.ips.main.ip6)} 135 ${builtins.concatStringsSep "\n" (map (i: "mta-sts${suffix} IN AAAA ${i}") config.myEnv.servers.eldiron.ips.main.ip6)}
diff --git a/modules/private/environment.nix b/modules/private/environment.nix
index 5f5f6c8..98d50b1 100644
--- a/modules/private/environment.nix
+++ b/modules/private/environment.nix
@@ -1,4 +1,4 @@
1{ lib, ... }: 1{ config, lib, name, ... }:
2with lib; 2with lib;
3with types; 3with types;
4with lists; 4with lists;
@@ -23,6 +23,7 @@ let
23 }; 23 };
24 mysqlOptions = { 24 mysqlOptions = {
25 host = mkOption { description = "Host to access Mysql"; type = str; }; 25 host = mkOption { description = "Host to access Mysql"; type = str; };
26 remoteHost = mkOption { description = "Host to access Mysql from outside"; type = str; };
26 port = mkOption { description = "Port to access Mysql"; type = str; }; 27 port = mkOption { description = "Port to access Mysql"; type = str; };
27 socket = mkOption { description = "Socket to access Mysql"; type = path; }; 28 socket = mkOption { description = "Socket to access Mysql"; type = path; };
28 systemUsers = mkOption { 29 systemUsers = mkOption {
@@ -107,6 +108,63 @@ let
107 }; 108 };
108 }; 109 };
109 }; 110 };
111 hostEnv = submodule {
112 options = {
113 fqdn = mkOption {
114 description = "Host FQDN";
115 type = str;
116 };
117 emails = mkOption {
118 default = [];
119 description = "List of e-mails that the server can be a sender of";
120 type = listOf str;
121 };
122 ldap = mkOption {
123 description = ''
124 LDAP credentials for the host
125 '';
126 type = submodule {
127 options = {
128 password = mkOption { type = string; description = "Password for the LDAP connection"; };
129 dn = mkOption { type = string; description = "DN for the LDAP connection"; };
130 };
131 };
132 };
133 mx = mkOption {
134 description = "subdomain and priority for MX server";
135 default = { enable = false; };
136 type = submodule {
137 options = {
138 enable = mkEnableOption "Enable MX";
139 subdomain = mkOption { type = nullOr str; description = "Subdomain name (mx-*)"; };
140 priority = mkOption { type = nullOr str; description = "Priority"; };
141 };
142 };
143 };
144 ips = mkOption {
145 description = ''
146 attrs of ip4/ip6 grouped by section
147 '';
148 type = attrsOf (submodule {
149 options = {
150 ip4 = mkOption {
151 type = string;
152 description = ''
153 ip4 address of the host
154 '';
155 };
156 ip6 = mkOption {
157 type = listOf string;
158 default = [];
159 description = ''
160 ip6 addresses of the host
161 '';
162 };
163 };
164 });
165 };
166 };
167 };
110in 168in
111{ 169{
112 options.myEnv = { 170 options.myEnv = {
@@ -115,48 +173,7 @@ in
115 Attrs of servers information in the cluster (not necessarily handled by nixops) 173 Attrs of servers information in the cluster (not necessarily handled by nixops)
116 ''; 174 '';
117 default = {}; 175 default = {};
118 type = attrsOf (submodule { 176 type = attrsOf hostEnv;
119 options = {
120 emails = mkOption {
121 default = [];
122 description = "List of e-mails that the server can be a sender of";
123 type = listOf str;
124 };
125 ldap = mkOption {
126 description = ''
127 LDAP credentials for the host
128 '';
129 type = submodule {
130 options = {
131 password = mkOption { type = string; description = "Password for the LDAP connection"; };
132 dn = mkOption { type = string; description = "DN for the LDAP connection"; };
133 };
134 };
135 };
136 ips = mkOption {
137 description = ''
138 attrs of ip4/ip6 grouped by section
139 '';
140 type = attrsOf (submodule {
141 options = {
142 ip4 = mkOption {
143 type = string;
144 description = ''
145 ip4 address of the host
146 '';
147 };
148 ip6 = mkOption {
149 type = listOf string;
150 default = [];
151 description = ''
152 ip6 addresses of the host
153 '';
154 };
155 };
156 });
157 };
158 };
159 });
160 }; 177 };
161 hetznerCloud = mkOption { 178 hetznerCloud = mkOption {
162 description = '' 179 description = ''
@@ -1172,12 +1189,10 @@ in
1172 ''; 1189 '';
1173 }; 1190 };
1174 }; 1191 };
1175 options.hostEnv = { 1192 options.hostEnv = mkOption {
1176 FQDN = mkOption { 1193 readOnly = true;
1177 type = string; 1194 type = hostEnv;
1178 description = '' 1195 default = config.myEnv.servers."${name}";
1179 FQDN of the current host. 1196 description = "Host environment";
1180 '';
1181 };
1182 }; 1197 };
1183} 1198}
diff --git a/modules/private/mail/default.nix b/modules/private/mail/default.nix
index a617934..b50e346 100644
--- a/modules/private/mail/default.nix
+++ b/modules/private/mail/default.nix
@@ -1,23 +1,25 @@
1{ lib, pkgs, config, ... }: 1{ lib, pkgs, config, ... }:
2{ 2{
3 imports = [ 3 imports = [
4 ./milters.nix 4 ./milters.nix
5 ./postfix.nix 5 ./postfix.nix
6 ./dovecot.nix 6 ./dovecot.nix
7 ./relay.nix
7 ./rspamd.nix 8 ./rspamd.nix
8 ./opensmtpd.nix 9 ./opensmtpd.nix
9 ]; 10 ];
10 options.myServices.mail.enable = lib.mkEnableOption "enable Mail services"; 11 options.myServices.mail.enable = lib.mkEnableOption "enable Mail services";
11 options.myServices.mailRelay.enable = lib.mkEnableOption "enable Mail relay services"; 12 options.myServices.mailRelay.enable = lib.mkEnableOption "enable Mail relay services";
13 options.myServices.mailBackup.enable = lib.mkEnableOption "enable MX backup services";
12 14
13 config = lib.mkIf config.myServices.mail.enable { 15 config = lib.mkIf config.myServices.mail.enable {
14 security.acme.certs."mail" = config.myServices.certificates.certConfig // { 16 security.acme.certs."mail" = config.myServices.certificates.certConfig // {
15 domain = "eldiron.immae.eu"; 17 domain = config.hostEnv.fqdn;
16 extraDomains = let 18 extraDomains = let
17 zonesWithMx = builtins.filter (zone: 19 zonesWithMx = builtins.filter (zone:
18 lib.attrsets.hasAttr "withEmail" zone && lib.lists.length zone.withEmail > 0 20 lib.attrsets.hasAttr "withEmail" zone && lib.lists.length zone.withEmail > 0
19 ) config.myEnv.dns.masterZones; 21 ) config.myEnv.dns.masterZones;
20 mxs = map (zone: "mx-1.${zone.name}") zonesWithMx; 22 mxs = map (zone: "${config.hostEnv.mx.subdomain}.${zone.name}") zonesWithMx;
21 in builtins.listToAttrs (map (mx: lib.attrsets.nameValuePair mx null) mxs); 23 in builtins.listToAttrs (map (mx: lib.attrsets.nameValuePair mx null) mxs);
22 }; 24 };
23 services.duplyBackup.profiles = { 25 services.duplyBackup.profiles = {
diff --git a/modules/private/mail/milters.nix b/modules/private/mail/milters.nix
index 6b033e8..16c8a7a 100644
--- a/modules/private/mail/milters.nix
+++ b/modules/private/mail/milters.nix
@@ -12,7 +12,7 @@
12 milters sockets 12 milters sockets
13 ''; 13 '';
14 }; 14 };
15 config = lib.mkIf config.myServices.mail.enable { 15 config = lib.mkIf (config.myServices.mail.enable || config.myServices.mailBackup.enable) {
16 secrets.keys = [ 16 secrets.keys = [
17 { 17 {
18 dest = "opendkim/eldiron.private"; 18 dest = "opendkim/eldiron.private";
@@ -34,7 +34,14 @@
34 user = config.services.opendmarc.user; 34 user = config.services.opendmarc.user;
35 group = config.services.opendmarc.group; 35 group = config.services.opendmarc.group;
36 permissions = "0400"; 36 permissions = "0400";
37 text = config.myEnv.mail.dmarc.ignore_hosts; 37 text = let
38 mxes = lib.attrsets.filterAttrs
39 (n: v: v.mx.enable)
40 config.myEnv.servers;
41 in
42 builtins.concatStringsSep "\n" ([
43 config.myEnv.mail.dmarc.ignore_hosts
44 ] ++ lib.mapAttrsToList (n: v: v.fqdn) mxes);
38 } 45 }
39 ]; 46 ];
40 users.users."${config.services.opendkim.user}".extraGroups = [ "keys" ]; 47 users.users."${config.services.opendkim.user}".extraGroups = [ "keys" ];
@@ -51,8 +58,9 @@
51 keyPath = "${config.secrets.location}/opendkim"; 58 keyPath = "${config.secrets.location}/opendkim";
52 selector = "eldiron"; 59 selector = "eldiron";
53 configFile = pkgs.writeText "opendkim.conf" '' 60 configFile = pkgs.writeText "opendkim.conf" ''
54 SubDomains yes 61 SubDomains yes
55 UMask 002 62 UMask 002
63 AlwaysAddARHeader yes
56 ''; 64 '';
57 group = config.services.postfix.group; 65 group = config.services.postfix.group;
58 }; 66 };
@@ -74,14 +82,14 @@
74 configFile = pkgs.writeText "opendmarc.conf" '' 82 configFile = pkgs.writeText "opendmarc.conf" ''
75 AuthservID HOSTNAME 83 AuthservID HOSTNAME
76 FailureReports false 84 FailureReports false
77 FailureReportsBcc postmaster@localhost.immae.eu 85 FailureReportsBcc postmaster@immae.eu
78 FailureReportsOnNone true 86 FailureReportsOnNone true
79 FailureReportsSentBy postmaster@immae.eu 87 FailureReportsSentBy postmaster@immae.eu
80 IgnoreAuthenticatedClients true 88 IgnoreAuthenticatedClients true
81 IgnoreHosts ${config.secrets.fullPaths."opendmarc/ignore.hosts"} 89 IgnoreHosts ${config.secrets.fullPaths."opendmarc/ignore.hosts"}
82 SoftwareHeader true 90 SoftwareHeader true
91 SPFIgnoreResults true
83 SPFSelfValidate true 92 SPFSelfValidate true
84 TrustedAuthservIDs HOSTNAME, immae.eu, nef2.ens.fr
85 UMask 002 93 UMask 002
86 ''; 94 '';
87 group = config.services.postfix.group; 95 group = config.services.postfix.group;
diff --git a/modules/private/mail/opensmtpd.nix b/modules/private/mail/opensmtpd.nix
index 7831ac0..e4a6140 100644
--- a/modules/private/mail/opensmtpd.nix
+++ b/modules/private/mail/opensmtpd.nix
@@ -8,7 +8,7 @@
8 group = "smtpd"; 8 group = "smtpd";
9 permissions = "0400"; 9 permissions = "0400";
10 text = '' 10 text = ''
11 eldiron ${name}:${config.myEnv.servers."${name}".ldap.password} 11 eldiron ${name}:${config.hostEnv.ldap.password}
12 ''; 12 '';
13 } 13 }
14 ]; 14 ];
@@ -22,12 +22,12 @@
22 # filter "fixfrom" \ 22 # filter "fixfrom" \
23 # proc-exec "${pkgs.procmail}/bin/formail -i 'From: ${name}@immae.eu'" 23 # proc-exec "${pkgs.procmail}/bin/formail -i 'From: ${name}@immae.eu'"
24 action "relay-rewrite-from" relay \ 24 action "relay-rewrite-from" relay \
25 helo ${config.hostEnv.FQDN} \ 25 helo ${config.hostEnv.fqdn} \
26 host smtp+tls://eldiron@eldiron.immae.eu:587 \ 26 host smtp+tls://eldiron@eldiron.immae.eu:587 \
27 auth <creds> \ 27 auth <creds> \
28 mail-from ${name}@immae.eu 28 mail-from ${name}@immae.eu
29 action "relay" relay \ 29 action "relay" relay \
30 helo ${config.hostEnv.FQDN} \ 30 helo ${config.hostEnv.fqdn} \
31 host smtp+tls://eldiron@eldiron.immae.eu:587 \ 31 host smtp+tls://eldiron@eldiron.immae.eu:587 \
32 auth <creds> 32 auth <creds>
33 match for any !mail-from "@immae.eu" action "relay-rewrite-from" 33 match for any !mail-from "@immae.eu" action "relay-rewrite-from"
diff --git a/modules/private/mail/postfix.nix b/modules/private/mail/postfix.nix
index 6623735..bd284cb 100644
--- a/modules/private/mail/postfix.nix
+++ b/modules/private/mail/postfix.nix
@@ -1,4 +1,4 @@
1{ lib, pkgs, config, nodes, ... }: 1{ lib, pkgs, config, nodes, name, ... }:
2{ 2{
3 config = lib.mkIf config.myServices.mail.enable { 3 config = lib.mkIf config.myServices.mail.enable {
4 services.duplyBackup.profiles.mail.excludeFile = '' 4 services.duplyBackup.profiles.mail.excludeFile = ''
@@ -299,8 +299,6 @@
299 lib.imap1 (i: m: "${m.type}:/etc/postfix/relay_${n}_${toString i}") v.recipient_maps 299 lib.imap1 (i: m: "${m.type}:/etc/postfix/relay_${n}_${toString i}") v.recipient_maps
300 ) config.myEnv.mail.postfix.backup_domains); 300 ) config.myEnv.mail.postfix.backup_domains);
301 smtpd_relay_restrictions = [ 301 smtpd_relay_restrictions = [
302 "permit_mynetworks"
303 "permit_sasl_authenticated"
304 "defer_unauth_destination" 302 "defer_unauth_destination"
305 ] ++ lib.flatten (lib.attrsets.mapAttrsToList (n: v: 303 ] ++ lib.flatten (lib.attrsets.mapAttrsToList (n: v:
306 if lib.attrsets.hasAttr "relay_restrictions" v 304 if lib.attrsets.hasAttr "relay_restrictions" v
@@ -317,8 +315,8 @@
317 smtp_tls_loglevel = "1"; 315 smtp_tls_loglevel = "1";
318 316
319 ### Force ip bind for smtp 317 ### Force ip bind for smtp
320 smtp_bind_address = config.myEnv.servers.eldiron.ips.main.ip4; 318 smtp_bind_address = config.hostEnv.ips.main.ip4;
321 smtp_bind_address6 = builtins.head config.myEnv.servers.eldiron.ips.main.ip6; 319 smtp_bind_address6 = builtins.head config.hostEnv.ips.main.ip6;
322 320
323 # Use some relays when authorized senders are not myself 321 # Use some relays when authorized senders are not myself
324 smtp_sasl_mechanism_filter = "plain,login"; # GSSAPI Not correctly supported by postfix 322 smtp_sasl_mechanism_filter = "plain,login"; # GSSAPI Not correctly supported by postfix
@@ -333,13 +331,11 @@
333 ### opendkim, opendmarc, openarc milters 331 ### opendkim, opendmarc, openarc milters
334 non_smtpd_milters = [ 332 non_smtpd_milters = [
335 "unix:${config.myServices.mail.milters.sockets.opendkim}" 333 "unix:${config.myServices.mail.milters.sockets.opendkim}"
336 "unix:${config.myServices.mail.milters.sockets.opendmarc}"
337 "unix:${config.myServices.mail.milters.sockets.openarc}"
338 ]; 334 ];
339 smtpd_milters = [ 335 smtpd_milters = [
340 "unix:${config.myServices.mail.milters.sockets.opendkim}" 336 "unix:${config.myServices.mail.milters.sockets.opendkim}"
341 "unix:${config.myServices.mail.milters.sockets.opendmarc}"
342 "unix:${config.myServices.mail.milters.sockets.openarc}" 337 "unix:${config.myServices.mail.milters.sockets.openarc}"
338 "unix:${config.myServices.mail.milters.sockets.opendmarc}"
343 ]; 339 ];
344 }; 340 };
345 enable = true; 341 enable = true;
@@ -357,6 +353,7 @@
357 smtpd_sasl_path = "private/auth"; 353 smtpd_sasl_path = "private/auth";
358 smtpd_reject_unlisted_recipient = "no"; 354 smtpd_reject_unlisted_recipient = "no";
359 smtpd_client_restrictions = "permit_sasl_authenticated,reject"; 355 smtpd_client_restrictions = "permit_sasl_authenticated,reject";
356 smtpd_relay_restrictions = "permit_sasl_authenticated,reject";
360 # Refuse to send e-mails with a From that is not handled 357 # Refuse to send e-mails with a From that is not handled
361 smtpd_sender_restrictions = 358 smtpd_sender_restrictions =
362 "reject_sender_login_mismatch,reject_unlisted_sender,permit_sasl_authenticated,reject"; 359 "reject_sender_login_mismatch,reject_unlisted_sender,permit_sasl_authenticated,reject";
@@ -378,7 +375,7 @@
378 ''; 375 '';
379 destination = ["localhost"]; 376 destination = ["localhost"];
380 # This needs to reverse DNS 377 # This needs to reverse DNS
381 hostname = "eldiron.immae.eu"; 378 hostname = config.hostEnv.fqdn;
382 setSendmail = true; 379 setSendmail = true;
383 sslCert = "/var/lib/acme/mail/fullchain.pem"; 380 sslCert = "/var/lib/acme/mail/fullchain.pem";
384 sslKey = "/var/lib/acme/mail/key.pem"; 381 sslKey = "/var/lib/acme/mail/key.pem";
diff --git a/modules/private/mail/relay.nix b/modules/private/mail/relay.nix
new file mode 100644
index 0000000..9111350
--- /dev/null
+++ b/modules/private/mail/relay.nix
@@ -0,0 +1,233 @@
1{ lib, pkgs, config, nodes, name, ... }:
2{
3 config = lib.mkIf config.myServices.mailBackup.enable {
4 security.acme.certs."mail" = config.myServices.certificates.certConfig // {
5 postRun = ''
6 systemctl restart postfix.service
7 '';
8 domain = config.hostEnv.fqdn;
9 extraDomains = let
10 zonesWithMx = builtins.filter (zone:
11 lib.attrsets.hasAttr "withEmail" zone && lib.lists.length zone.withEmail > 0
12 ) config.myEnv.dns.masterZones;
13 mxs = map (zone: "${config.myEnv.servers."${name}".mx.subdomain}.${zone.name}") zonesWithMx;
14 in builtins.listToAttrs (map (mx: lib.attrsets.nameValuePair mx null) mxs);
15 };
16 secrets.keys = [
17 {
18 dest = "postfix/mysql_alias_maps";
19 user = config.services.postfix.user;
20 group = config.services.postfix.group;
21 permissions = "0440";
22 text = ''
23 # We need to specify that option to trigger ssl connection
24 tls_ciphers = TLSv1.2
25 user = ${config.myEnv.mail.postfix.mysql.user}
26 password = ${config.myEnv.mail.postfix.mysql.password}
27 hosts = ${config.myEnv.mail.postfix.mysql.remoteHost}
28 dbname = ${config.myEnv.mail.postfix.mysql.database}
29 query = SELECT DISTINCT 1
30 FROM forwardings_merge
31 WHERE
32 ((regex = 1 AND '%s' REGEXP CONCAT('^',source,'$') ) OR (regex = 0 AND source = '%s'))
33 AND active = 1
34 AND '%s' NOT IN
35 (
36 SELECT source
37 FROM forwardings_blacklisted
38 WHERE source = '%s'
39 ) UNION
40 SELECT 'devnull@immae.eu'
41 FROM forwardings_blacklisted
42 WHERE source = '%s'
43 '';
44 }
45 {
46 dest = "postfix/mysql_mailbox_maps";
47 user = config.services.postfix.user;
48 group = config.services.postfix.group;
49 permissions = "0440";
50 text = ''
51 # We need to specify that option to trigger ssl connection
52 tls_ciphers = TLSv1.2
53 user = ${config.myEnv.mail.postfix.mysql.user}
54 password = ${config.myEnv.mail.postfix.mysql.password}
55 hosts = ${config.myEnv.mail.postfix.mysql.remoteHost}
56 dbname = ${config.myEnv.mail.postfix.mysql.database}
57 query = SELECT DISTINCT 1
58 FROM mailboxes
59 WHERE active = 1
60 AND (
61 (domain = '%d' AND user = '%u' AND regex = 0)
62 OR (
63 regex = 1
64 AND '%d' REGEXP CONCAT('^',domain,'$')
65 AND '%u' REGEXP CONCAT('^',user,'$')
66 )
67 )
68 LIMIT 1
69 '';
70 }
71 {
72 dest = "postfix/ldap_ejabberd_users_immae_fr";
73 user = config.services.postfix.user;
74 group = config.services.postfix.group;
75 permissions = "0440";
76 text = ''
77 server_host = ldaps://${config.myEnv.jabber.ldap.host}:636
78 search_base = ${config.myEnv.jabber.ldap.base}
79 query_filter = ${config.myEnv.jabber.postfix_user_filter}
80 domain = immae.fr
81 bind_dn = ${config.myEnv.jabber.ldap.dn}
82 bind_pw = ${config.myEnv.jabber.ldap.password}
83 result_attribute = immaeXmppUid
84 result_format = ejabberd@localhost
85 version = 3
86 '';
87 }
88 ];
89
90 networking.firewall.allowedTCPPorts = [ 25 ];
91
92 nixpkgs.overlays = [ (self: super: {
93 postfix = super.postfix.override { withMySQL = true; };
94 }) ];
95 users.users."${config.services.postfix.user}".extraGroups = [ "keys" ];
96 services.filesWatcher.postfix = {
97 restart = true;
98 paths = [
99 config.secrets.fullPaths."postfix/mysql_alias_maps"
100 config.secrets.fullPaths."postfix/mysql_mailbox_maps"
101 config.secrets.fullPaths."postfix/ldap_ejabberd_users_immae_fr"
102 ];
103 };
104 services.postfix = {
105 mapFiles = let
106 recipient_maps = let
107 name = n: i: "relay_${n}_${toString i}";
108 pair = n: i: m: lib.attrsets.nameValuePair (name n i) (
109 if m.type == "hash"
110 then pkgs.writeText (name n i) m.content
111 else null
112 );
113 pairs = n: v: lib.imap1 (i: m: pair n i m) v.recipient_maps;
114 in lib.attrsets.filterAttrs (k: v: v != null) (
115 lib.attrsets.listToAttrs (lib.flatten (
116 lib.attrsets.mapAttrsToList pairs config.myEnv.mail.postfix.backup_domains
117 ))
118 );
119 relay_restrictions = lib.attrsets.filterAttrs (k: v: v != null) (
120 lib.attrsets.mapAttrs' (n: v:
121 lib.attrsets.nameValuePair "recipient_access_${n}" (
122 if lib.attrsets.hasAttr "relay_restrictions" v
123 then pkgs.writeText "recipient_access_${n}" v.relay_restrictions
124 else null
125 )
126 ) config.myEnv.mail.postfix.backup_domains
127 );
128 virtual_map = {
129 virtual = pkgs.writeText "postfix-virtual" (
130 builtins.concatStringsSep "\n" (
131 lib.attrsets.mapAttrsToList (
132 n: v: lib.optionalString v.external ''
133 script_${n}@mail.immae.eu 1
134 ''
135 ) config.myEnv.mail.scripts
136 )
137 );
138 };
139 sasl_access = {
140 host_dummy_mailboxes = pkgs.writeText "host-virtual-mailbox"
141 (builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: "${n}@immae.eu 1") nodes));
142 };
143 in
144 recipient_maps // relay_restrictions // virtual_map // sasl_access;
145 config = {
146 ### postfix module overrides
147 readme_directory = "${pkgs.postfix}/share/postfix/doc";
148 smtp_tls_CAfile = lib.mkForce "";
149 smtp_tls_cert_file = lib.mkForce "";
150 smtp_tls_key_file = lib.mkForce "";
151
152 message_size_limit = "1073741824"; # Don't put 0 here, it's not equivalent to "unlimited"
153 mailbox_size_limit = "1073741825"; # Workaround, local delivered mails should all go through scripts
154 alias_database = "\$alias_maps";
155
156 ### Relay domains
157 relay_domains = let
158 backups = lib.flatten (lib.attrsets.mapAttrsToList (n: v: v.domains or []) config.myEnv.mail.postfix.backup_domains);
159 virtual_domains = config.myEnv.mail.postfix.additional_mailbox_domains
160 ++ lib.remove "localhost.immae.eu" (lib.remove null (lib.flatten (map
161 (zone: map
162 (e: if e.receive
163 then "${e.domain}${lib.optionalString (e.domain != "") "."}${zone.name}"
164 else null
165 )
166 (zone.withEmail or [])
167 )
168 config.myEnv.dns.masterZones
169 )));
170 in
171 backups ++ virtual_domains;
172 relay_recipient_maps = let
173 backup_recipients = lib.flatten (lib.attrsets.mapAttrsToList (n: v:
174 lib.imap1 (i: m: "${m.type}:/etc/postfix/relay_${n}_${toString i}") v.recipient_maps
175 ) config.myEnv.mail.postfix.backup_domains);
176 virtual_alias_maps = [
177 "hash:/etc/postfix/virtual"
178 "mysql:${config.secrets.fullPaths."postfix/mysql_alias_maps"}"
179 "ldap:${config.secrets.fullPaths."postfix/ldap_ejabberd_users_immae_fr"}"
180 ];
181 virtual_mailbox_maps = [
182 "hash:/etc/postfix/host_dummy_mailboxes"
183 "mysql:${config.secrets.fullPaths."postfix/mysql_mailbox_maps"}"
184 ];
185 in
186 backup_recipients ++ virtual_alias_maps ++ virtual_mailbox_maps;
187 smtpd_relay_restrictions = [
188 "defer_unauth_destination"
189 ] ++ lib.flatten (lib.attrsets.mapAttrsToList (n: v:
190 if lib.attrsets.hasAttr "relay_restrictions" v
191 then [ "check_recipient_access hash:/etc/postfix/recipient_access_${n}" ]
192 else []
193 ) config.myEnv.mail.postfix.backup_domains);
194
195 ### Additional smtpd configuration
196 smtpd_tls_received_header = "yes";
197 smtpd_tls_loglevel = "1";
198
199 ### Email sending configuration
200 smtp_tls_security_level = "may";
201 smtp_tls_loglevel = "1";
202
203 ### Force ip bind for smtp
204 smtp_bind_address = config.myEnv.servers."${name}".ips.main.ip4;
205 smtp_bind_address6 = builtins.head config.myEnv.servers."${name}".ips.main.ip6;
206
207 smtpd_milters = [
208 "unix:${config.myServices.mail.milters.sockets.opendkim}"
209 "unix:${config.myServices.mail.milters.sockets.openarc}"
210 "unix:${config.myServices.mail.milters.sockets.opendmarc}"
211 ];
212 };
213 enable = true;
214 enableSmtp = true;
215 enableSubmission = false;
216 # FIXME: Mail adressed to localhost.immae.eu will still have mx-1 as
217 # prioritized MX, which provokes "mail for localhost.immae.eu loops
218 # back to myself" errors. This transport entry forces to push
219 # e-mails to its right destination.
220 transport = ''
221 localhost.immae.eu smtp:[immae.eu]:25
222 '';
223 destination = ["localhost"];
224 # This needs to reverse DNS
225 hostname = config.hostEnv.fqdn;
226 setSendmail = false;
227 sslCert = "/var/lib/acme/mail/fullchain.pem";
228 sslKey = "/var/lib/acme/mail/key.pem";
229 recipientDelimiter = "+";
230 };
231 };
232}
233
diff --git a/modules/private/monitoring/default.nix b/modules/private/monitoring/default.nix
index a1f4b3f..2c2f693 100644
--- a/modules/private/monitoring/default.nix
+++ b/modules/private/monitoring/default.nix
@@ -85,7 +85,7 @@ let
85 masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; }; 85 masterObjects = pkgs.callPackage ./objects_master.nix { inherit config; };
86 commonObjects = pkgs.callPackage ./objects_common.nix ({ 86 commonObjects = pkgs.callPackage ./objects_common.nix ({
87 master = cfg.master; 87 master = cfg.master;
88 hostFQDN = config.hostEnv.FQDN; 88 hostFQDN = config.hostEnv.fqdn;
89 hostName = name; 89 hostName = name;
90 sudo = "/run/wrappers/bin/sudo"; 90 sudo = "/run/wrappers/bin/sudo";
91 } // builtins.getAttr name commonConfig); 91 } // builtins.getAttr name commonConfig);
@@ -97,7 +97,7 @@ let
97 (builtins.pathExists specific_file) 97 (builtins.pathExists specific_file)
98 (pkgs.callPackage specific_file { 98 (pkgs.callPackage specific_file {
99 inherit config; 99 inherit config;
100 hostFQDN = config.hostEnv.FQDN; 100 hostFQDN = config.hostEnv.fqdn;
101 hostName = name; 101 hostName = name;
102 }); 102 });
103in 103in
diff --git a/modules/private/monitoring/status.nix b/modules/private/monitoring/status.nix
index ed4d681..d25d934 100644
--- a/modules/private/monitoring/status.nix
+++ b/modules/private/monitoring/status.nix
@@ -37,7 +37,7 @@
37 security.acme.certs."${name}".extraDomains."status.immae.eu" = null; 37 security.acme.certs."${name}".extraDomains."status.immae.eu" = null;
38 38
39 myServices.certificates.enable = true; 39 myServices.certificates.enable = true;
40 networking.firewall.allowedTCPPorts = [ 80 443 18000 ]; 40 networking.firewall.allowedTCPPorts = [ 80 443 ];
41 systemd.services.naemon-status = { 41 systemd.services.naemon-status = {
42 description = "Naemon status"; 42 description = "Naemon status";
43 after = [ "network.target" ]; 43 after = [ "network.target" ];
diff --git a/modules/private/system.nix b/modules/private/system.nix
index 184add5..66208c4 100644
--- a/modules/private/system.nix
+++ b/modules/private/system.nix
@@ -1,4 +1,4 @@
1{ pkgs, lib, ... }: 1{ pkgs, lib, config, name, ... }:
2{ 2{
3 config = { 3 config = {
4 services.duplyBackup.profiles.system = { 4 services.duplyBackup.profiles.system = {
diff --git a/modules/private/system/backup-2.nix b/modules/private/system/backup-2.nix
index ede5bc2..1d84667 100644
--- a/modules/private/system/backup-2.nix
+++ b/modules/private/system/backup-2.nix
@@ -1,9 +1,8 @@
1{ privateFiles }: 1{ privateFiles }:
2{ config, pkgs, resources, name, ... }: 2{ config, pkgs, resources, ... }:
3{ 3{
4 boot.kernelPackages = pkgs.linuxPackages_latest; 4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; 5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
6 hostEnv.FQDN = "backup-2.v.immae.eu";
7 6
8 imports = builtins.attrValues (import ../..); 7 imports = builtins.attrValues (import ../..);
9 8
@@ -28,13 +27,22 @@
28 firewall.enable = true; 27 firewall.enable = true;
29 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList 28 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
30 (n: ips: { address = ips.ip4; prefixLength = 32; }) 29 (n: ips: { address = ips.ip4; prefixLength = 32; })
31 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.myEnv.servers.backup-2.ips); 30 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
32 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList 31 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
33 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) 32 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
34 config.myEnv.servers.backup-2.ips); 33 config.hostEnv.ips);
35 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; 34 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
36 }; 35 };
37 36
37 myServices.certificates.enable = true;
38 services.nginx = {
39 enable = true;
40 recommendedOptimisation = true;
41 recommendedGzipSettings = true;
42 recommendedProxySettings = true;
43 };
44 networking.firewall.allowedTCPPorts = [ 80 443 ];
45
38 services.cron = { 46 services.cron = {
39 mailto = "cron@immae.eu"; 47 mailto = "cron@immae.eu";
40 enable = true; 48 enable = true;
@@ -49,6 +57,7 @@
49 }; 57 };
50 58
51 myServices.mailRelay.enable = true; 59 myServices.mailRelay.enable = true;
60 myServices.mailBackup.enable = true;
52 myServices.monitoring.enable = true; 61 myServices.monitoring.enable = true;
53 myServices.databasesReplication = { 62 myServices.databasesReplication = {
54 postgresql = { 63 postgresql = {
@@ -57,7 +66,7 @@
57 hosts = { 66 hosts = {
58 eldiron = { 67 eldiron = {
59 slot = "backup_2"; 68 slot = "backup_2";
60 connection = "postgresql://backup-2:${config.myEnv.servers.backup-2.ldap.password}@eldiron.immae.eu"; 69 connection = "postgresql://backup-2:${config.hostEnv.ldap.password}@eldiron.immae.eu";
61 }; 70 };
62 }; 71 };
63 }; 72 };
@@ -71,7 +80,7 @@
71 host = config.myEnv.servers.eldiron.ips.main.ip4; 80 host = config.myEnv.servers.eldiron.ips.main.ip4;
72 port = "3306"; 81 port = "3306";
73 user = "backup-2"; 82 user = "backup-2";
74 password = config.myEnv.servers.backup-2.ldap.password; 83 password = config.hostEnv.ldap.password;
75 dumpUser = "root"; 84 dumpUser = "root";
76 dumpPassword = config.myEnv.databases.mysql.systemUsers.root; 85 dumpPassword = config.myEnv.databases.mysql.systemUsers.root;
77 }; 86 };
diff --git a/modules/private/system/eldiron.nix b/modules/private/system/eldiron.nix
index bbe1345..0490cfc 100644
--- a/modules/private/system/eldiron.nix
+++ b/modules/private/system/eldiron.nix
@@ -3,17 +3,16 @@
3{ 3{
4 boot.kernelPackages = pkgs.linuxPackages_latest; 4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; 5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
6 hostEnv.FQDN = "eldiron.immae.eu";
7 6
8 networking = { 7 networking = {
9 firewall.enable = true; 8 firewall.enable = true;
10 # 176.9.151.89 declared in nixops -> infra / tools 9 # 176.9.151.89 declared in nixops -> infra / tools
11 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList 10 interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
12 (n: ips: { address = ips.ip4; prefixLength = 32; }) 11 (n: ips: { address = ips.ip4; prefixLength = 32; })
13 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.myEnv.servers.eldiron.ips); 12 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
14 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList 13 interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
15 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) 14 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
16 config.myEnv.servers.eldiron.ips); 15 config.hostEnv.ips);
17 }; 16 };
18 17
19 imports = builtins.attrValues (import ../..); 18 imports = builtins.attrValues (import ../..);
@@ -44,7 +43,7 @@
44 hetzner = { 43 hetzner = {
45 robotUser = config.myEnv.hetzner.user; 44 robotUser = config.myEnv.hetzner.user;
46 robotPass = config.myEnv.hetzner.pass; 45 robotPass = config.myEnv.hetzner.pass;
47 mainIPv4 = config.myEnv.servers.eldiron.ips.main.ip4; 46 mainIPv4 = config.hostEnv.ips.main.ip4;
48 partitions = '' 47 partitions = ''
49 clearpart --all --initlabel --drives=sda,sdb 48 clearpart --all --initlabel --drives=sda,sdb
50 49
diff --git a/modules/private/system/monitoring-1.nix b/modules/private/system/monitoring-1.nix
index 1460478..20c12df 100644
--- a/modules/private/system/monitoring-1.nix
+++ b/modules/private/system/monitoring-1.nix
@@ -3,7 +3,6 @@
3{ 3{
4 boot.kernelPackages = pkgs.linuxPackages_latest; 4 boot.kernelPackages = pkgs.linuxPackages_latest;
5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; }; 5 myEnv = import "${privateFiles}/environment.nix" // { inherit privateFiles; };
6 hostEnv.FQDN = "monitoring-1.v.immae.eu";
7 6
8 imports = builtins.attrValues (import ../..); 7 imports = builtins.attrValues (import ../..);
9 8
@@ -24,10 +23,10 @@
24 firewall.enable = true; 23 firewall.enable = true;
25 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList 24 interfaces."ens3".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList
26 (n: ips: { address = ips.ip4; prefixLength = 32; }) 25 (n: ips: { address = ips.ip4; prefixLength = 32; })
27 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.myEnv.servers.monitoring-1.ips); 26 (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") config.hostEnv.ips);
28 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList 27 interfaces."ens3".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList
29 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) 28 (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or []))
30 config.myEnv.servers.monitoring-1.ips); 29 config.hostEnv.ips);
31 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; }; 30 defaultGateway6 = { address = "fe80::1"; interface = "ens3"; };
32 }; 31 };
33 myServices.mailRelay.enable = true; 32 myServices.mailRelay.enable = true;
diff --git a/modules/private/websites/tools/git/mantisbt.nix b/modules/private/websites/tools/git/mantisbt.nix
index d0d7a98..8606819 100644
--- a/modules/private/websites/tools/git/mantisbt.nix
+++ b/modules/private/websites/tools/git/mantisbt.nix
@@ -31,7 +31,7 @@ rec {
31 $g_from_email = 'mantisbt@tools.immae.eu'; 31 $g_from_email = 'mantisbt@tools.immae.eu';
32 $g_return_path_email = 'mantisbt@tools.immae.eu'; 32 $g_return_path_email = 'mantisbt@tools.immae.eu';
33 $g_from_name = 'Mantis Bug Tracker at git.immae.eu'; 33 $g_from_name = 'Mantis Bug Tracker at git.immae.eu';
34 $g_email_receive_own = OFF; 34 $g_email_receive_own = ON;
35 # --- LDAP --- 35 # --- LDAP ---
36 $g_login_method = LDAP; 36 $g_login_method = LDAP;
37 $g_ldap_protocol_version = 3; 37 $g_ldap_protocol_version = 3;
diff --git a/modules/private/websites/tools/mail/mta-sts.nix b/modules/private/websites/tools/mail/mta-sts.nix
index a401b41..ed3fce8 100644
--- a/modules/private/websites/tools/mail/mta-sts.nix
+++ b/modules/private/websites/tools/mail/mta-sts.nix
@@ -13,13 +13,15 @@ let
13 ) 13 )
14 config.myEnv.dns.masterZones 14 config.myEnv.dns.masterZones
15 ))); 15 )));
16 mxes = lib.mapAttrsToList
17 (n: v: v.mx.subdomain)
18 (lib.attrsets.filterAttrs (n: v: v.mx.enable) config.myEnv.servers);
16 # FIXME: increase the id number in modules/private/dns.nix when this 19 # FIXME: increase the id number in modules/private/dns.nix when this
17 # file change (date -u +'%Y%m%d%H%M%S'Z) 20 # file change (date -u +'%Y%m%d%H%M%S'Z)
18 file = domain: pkgs.writeText "mta-sts-${domain.domain}.txt" '' 21 file = domain: pkgs.writeText "mta-sts-${domain.domain}.txt" ''
19 version: STSv1 22 version: STSv1
20 mode: testing 23 mode: testing
21 mx: mx-1.${domain.mail} 24 ${builtins.concatStringsSep "\n" (map (v: "mx: ${v}.${domain.mail}") mxes)}
22 mx: mx-2.${domain.mail}
23 max_age: 604800 25 max_age: 604800
24 ''; 26 '';
25 root = pkgs.runCommand "mta-sts_root" {} '' 27 root = pkgs.runCommand "mta-sts_root" {} ''