diff options
Diffstat (limited to 'modules/private/mail/postfix.nix')
-rw-r--r-- | modules/private/mail/postfix.nix | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/modules/private/mail/postfix.nix b/modules/private/mail/postfix.nix index a679027..f8f86f6 100644 --- a/modules/private/mail/postfix.nix +++ b/modules/private/mail/postfix.nix | |||
@@ -1,4 +1,4 @@ | |||
1 | { lib, pkgs, config, myconfig, ... }: | 1 | { lib, pkgs, config, ... }: |
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 = '' |
@@ -13,10 +13,10 @@ | |||
13 | text = '' | 13 | text = '' |
14 | # We need to specify that option to trigger ssl connection | 14 | # We need to specify that option to trigger ssl connection |
15 | tls_ciphers = TLSv1.2 | 15 | tls_ciphers = TLSv1.2 |
16 | user = ${myconfig.env.mail.postfix.mysql.user} | 16 | user = ${config.myEnv.mail.postfix.mysql.user} |
17 | password = ${myconfig.env.mail.postfix.mysql.password} | 17 | password = ${config.myEnv.mail.postfix.mysql.password} |
18 | hosts = unix:${myconfig.env.mail.postfix.mysql.socket} | 18 | hosts = unix:${config.myEnv.mail.postfix.mysql.socket} |
19 | dbname = ${myconfig.env.mail.postfix.mysql.database} | 19 | dbname = ${config.myEnv.mail.postfix.mysql.database} |
20 | query = SELECT DISTINCT destination | 20 | query = SELECT DISTINCT destination |
21 | FROM forwardings_merge | 21 | FROM forwardings_merge |
22 | WHERE | 22 | WHERE |
@@ -41,10 +41,10 @@ | |||
41 | text = '' | 41 | text = '' |
42 | # We need to specify that option to trigger ssl connection | 42 | # We need to specify that option to trigger ssl connection |
43 | tls_ciphers = TLSv1.2 | 43 | tls_ciphers = TLSv1.2 |
44 | user = ${myconfig.env.mail.postfix.mysql.user} | 44 | user = ${config.myEnv.mail.postfix.mysql.user} |
45 | password = ${myconfig.env.mail.postfix.mysql.password} | 45 | password = ${config.myEnv.mail.postfix.mysql.password} |
46 | hosts = unix:${myconfig.env.mail.postfix.mysql.socket} | 46 | hosts = unix:${config.myEnv.mail.postfix.mysql.socket} |
47 | dbname = ${myconfig.env.mail.postfix.mysql.database} | 47 | dbname = ${config.myEnv.mail.postfix.mysql.database} |
48 | result_format = /%d/%u | 48 | result_format = /%d/%u |
49 | query = SELECT DISTINCT '%s' | 49 | query = SELECT DISTINCT '%s' |
50 | FROM mailboxes | 50 | FROM mailboxes |
@@ -68,10 +68,10 @@ | |||
68 | text = '' | 68 | text = '' |
69 | # We need to specify that option to trigger ssl connection | 69 | # We need to specify that option to trigger ssl connection |
70 | tls_ciphers = TLSv1.2 | 70 | tls_ciphers = TLSv1.2 |
71 | user = ${myconfig.env.mail.postfix.mysql.user} | 71 | user = ${config.myEnv.mail.postfix.mysql.user} |
72 | password = ${myconfig.env.mail.postfix.mysql.password} | 72 | password = ${config.myEnv.mail.postfix.mysql.password} |
73 | hosts = unix:${myconfig.env.mail.postfix.mysql.socket} | 73 | hosts = unix:${config.myEnv.mail.postfix.mysql.socket} |
74 | dbname = ${myconfig.env.mail.postfix.mysql.database} | 74 | dbname = ${config.myEnv.mail.postfix.mysql.database} |
75 | query = SELECT DISTINCT destination | 75 | query = SELECT DISTINCT destination |
76 | FROM forwardings_merge | 76 | FROM forwardings_merge |
77 | WHERE | 77 | WHERE |
@@ -132,7 +132,7 @@ | |||
132 | ''; | 132 | ''; |
133 | scripts = lib.attrsets.mapAttrs (n: v: | 133 | scripts = lib.attrsets.mapAttrs (n: v: |
134 | toScript n (pkgs.callPackage (builtins.fetchGit { url = v.src.url; ref = "master"; rev = v.src.rev; }) { scriptEnv = v.env; }) | 134 | toScript n (pkgs.callPackage (builtins.fetchGit { url = v.src.url; ref = "master"; rev = v.src.rev; }) { scriptEnv = v.env; }) |
135 | ) myconfig.env.mail.scripts; | 135 | ) config.myEnv.mail.scripts; |
136 | in builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: ''${n}: "|${v}"'') scripts); | 136 | in builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList (n: v: ''${n}: "|${v}"'') scripts); |
137 | mapFiles = let | 137 | mapFiles = let |
138 | recipient_maps = let | 138 | recipient_maps = let |
@@ -145,7 +145,7 @@ | |||
145 | pairs = n: v: lib.imap1 (i: m: pair n i m) v.recipient_maps; | 145 | pairs = n: v: lib.imap1 (i: m: pair n i m) v.recipient_maps; |
146 | in lib.attrsets.filterAttrs (k: v: v != null) ( | 146 | in lib.attrsets.filterAttrs (k: v: v != null) ( |
147 | lib.attrsets.listToAttrs (lib.flatten ( | 147 | lib.attrsets.listToAttrs (lib.flatten ( |
148 | lib.attrsets.mapAttrsToList pairs myconfig.env.mail.postfix.backup_domains | 148 | lib.attrsets.mapAttrsToList pairs config.myEnv.mail.postfix.backup_domains |
149 | )) | 149 | )) |
150 | ); | 150 | ); |
151 | relay_restrictions = lib.attrsets.filterAttrs (k: v: v != null) ( | 151 | relay_restrictions = lib.attrsets.filterAttrs (k: v: v != null) ( |
@@ -155,7 +155,7 @@ | |||
155 | then pkgs.writeText "recipient_access_${n}" v.relay_restrictions | 155 | then pkgs.writeText "recipient_access_${n}" v.relay_restrictions |
156 | else null | 156 | else null |
157 | ) | 157 | ) |
158 | ) myconfig.env.mail.postfix.backup_domains | 158 | ) config.myEnv.mail.postfix.backup_domains |
159 | ); | 159 | ); |
160 | virtual_map = { | 160 | virtual_map = { |
161 | virtual = pkgs.writeText "postfix-virtual" ( | 161 | virtual = pkgs.writeText "postfix-virtual" ( |
@@ -164,7 +164,7 @@ | |||
164 | n: v: '' | 164 | n: v: '' |
165 | script_${n}@mail.immae.eu ${n}@localhost, scripts@mail.immae.eu | 165 | script_${n}@mail.immae.eu ${n}@localhost, scripts@mail.immae.eu |
166 | '' | 166 | '' |
167 | ) myconfig.env.mail.scripts | 167 | ) config.myEnv.mail.scripts |
168 | ) | 168 | ) |
169 | ); | 169 | ); |
170 | }; | 170 | }; |
@@ -183,7 +183,7 @@ | |||
183 | 183 | ||
184 | ### Virtual mailboxes config | 184 | ### Virtual mailboxes config |
185 | virtual_alias_maps = "hash:/etc/postfix/virtual mysql:${config.secrets.fullPaths."postfix/mysql_alias_maps"}"; | 185 | virtual_alias_maps = "hash:/etc/postfix/virtual mysql:${config.secrets.fullPaths."postfix/mysql_alias_maps"}"; |
186 | virtual_mailbox_domains = myconfig.env.mail.postfix.additional_mailbox_domains | 186 | virtual_mailbox_domains = config.myEnv.mail.postfix.additional_mailbox_domains |
187 | ++ lib.remove "localhost.immae.eu" (lib.remove null (lib.flatten (map | 187 | ++ lib.remove "localhost.immae.eu" (lib.remove null (lib.flatten (map |
188 | (zone: map | 188 | (zone: map |
189 | (e: if e.receive | 189 | (e: if e.receive |
@@ -192,17 +192,17 @@ | |||
192 | ) | 192 | ) |
193 | (zone.withEmail or []) | 193 | (zone.withEmail or []) |
194 | ) | 194 | ) |
195 | myconfig.env.dns.masterZones | 195 | config.myEnv.dns.masterZones |
196 | ))); | 196 | ))); |
197 | virtual_mailbox_maps = "mysql:${config.secrets.fullPaths."postfix/mysql_mailbox_maps"}"; | 197 | virtual_mailbox_maps = "mysql:${config.secrets.fullPaths."postfix/mysql_mailbox_maps"}"; |
198 | dovecot_destination_recipient_limit = "1"; | 198 | dovecot_destination_recipient_limit = "1"; |
199 | virtual_transport = "dovecot"; | 199 | virtual_transport = "dovecot"; |
200 | 200 | ||
201 | ### Relay domains | 201 | ### Relay domains |
202 | relay_domains = lib.flatten (lib.attrsets.mapAttrsToList (n: v: v.domains or []) myconfig.env.mail.postfix.backup_domains); | 202 | relay_domains = lib.flatten (lib.attrsets.mapAttrsToList (n: v: v.domains or []) config.myEnv.mail.postfix.backup_domains); |
203 | relay_recipient_maps = lib.flatten (lib.attrsets.mapAttrsToList (n: v: | 203 | relay_recipient_maps = lib.flatten (lib.attrsets.mapAttrsToList (n: v: |
204 | lib.imap1 (i: m: "${m.type}:/etc/postfix/relay_${n}_${toString i}") v.recipient_maps | 204 | lib.imap1 (i: m: "${m.type}:/etc/postfix/relay_${n}_${toString i}") v.recipient_maps |
205 | ) myconfig.env.mail.postfix.backup_domains); | 205 | ) config.myEnv.mail.postfix.backup_domains); |
206 | smtpd_relay_restrictions = [ | 206 | smtpd_relay_restrictions = [ |
207 | "permit_mynetworks" | 207 | "permit_mynetworks" |
208 | "permit_sasl_authenticated" | 208 | "permit_sasl_authenticated" |
@@ -211,7 +211,7 @@ | |||
211 | if lib.attrsets.hasAttr "relay_restrictions" v | 211 | if lib.attrsets.hasAttr "relay_restrictions" v |
212 | then [ "check_recipient_access hash:/etc/postfix/recipient_access_${n}" ] | 212 | then [ "check_recipient_access hash:/etc/postfix/recipient_access_${n}" ] |
213 | else [] | 213 | else [] |
214 | ) myconfig.env.mail.postfix.backup_domains); | 214 | ) config.myEnv.mail.postfix.backup_domains); |
215 | 215 | ||
216 | ### Additional smtpd configuration | 216 | ### Additional smtpd configuration |
217 | smtpd_tls_received_header = "yes"; | 217 | smtpd_tls_received_header = "yes"; |
@@ -222,8 +222,8 @@ | |||
222 | smtp_tls_loglevel = "1"; | 222 | smtp_tls_loglevel = "1"; |
223 | 223 | ||
224 | ### Force ip bind for smtp | 224 | ### Force ip bind for smtp |
225 | smtp_bind_address = myconfig.env.servers.eldiron.ips.main.ip4; | 225 | smtp_bind_address = config.myEnv.servers.eldiron.ips.main.ip4; |
226 | smtp_bind_address6 = builtins.head myconfig.env.servers.eldiron.ips.main.ip6; | 226 | smtp_bind_address6 = builtins.head config.myEnv.servers.eldiron.ips.main.ip6; |
227 | 227 | ||
228 | # #Unneeded if postfix can only send e-mail from "self" domains | 228 | # #Unneeded if postfix can only send e-mail from "self" domains |
229 | # #smtp_sasl_auth_enable = "yes"; | 229 | # #smtp_sasl_auth_enable = "yes"; |