aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-26 18:55:50 +0100
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-12-26 18:55:50 +0100
commit5b53d86f38bd8e42695a62be9a833beb66bbbba3 (patch)
tree06e16e284f47ffef7c7a1c9095b37fc4ce39e8e1
parent106b1198698056047f5f18e627ba58b9aaec70f4 (diff)
downloadNix-5b53d86f38bd8e42695a62be9a833beb66bbbba3.tar.gz
Nix-5b53d86f38bd8e42695a62be9a833beb66bbbba3.tar.zst
Nix-5b53d86f38bd8e42695a62be9a833beb66bbbba3.zip
Add xmpp-mail bridge
-rw-r--r--modules/private/environment.nix2
-rw-r--r--modules/private/mail/postfix.nix22
2 files changed, 22 insertions, 2 deletions
diff --git a/modules/private/environment.nix b/modules/private/environment.nix
index 15e8f54..9bfb80a 100644
--- a/modules/private/environment.nix
+++ b/modules/private/environment.nix
@@ -259,6 +259,7 @@ in
259 description = "Jabber configuration"; 259 description = "Jabber configuration";
260 type = submodule { 260 type = submodule {
261 options = { 261 options = {
262 postfix_user_filter = mkOption { type = str; description = "Postfix filter to get xmpp users"; };
262 ldap = mkLdapOptions "Jabber" {}; 263 ldap = mkLdapOptions "Jabber" {};
263 postgresql = mkPsqlOptions "Jabber"; 264 postgresql = mkPsqlOptions "Jabber";
264 }; 265 };
@@ -593,6 +594,7 @@ in
593 description = "Mail script recipients"; 594 description = "Mail script recipients";
594 type = attrsOf (submodule { 595 type = attrsOf (submodule {
595 options = { 596 options = {
597 external = mkEnableOption "Create a script_<name>@mail.immae.eu external address";
596 src = mkOption { 598 src = mkOption {
597 description = '' 599 description = ''
598 git source to fetch the script from. 600 git source to fetch the script from.
diff --git a/modules/private/mail/postfix.nix b/modules/private/mail/postfix.nix
index f8f86f6..9c4b87c 100644
--- a/modules/private/mail/postfix.nix
+++ b/modules/private/mail/postfix.nix
@@ -80,6 +80,23 @@
80 UNION SELECT '%s' AS destination 80 UNION SELECT '%s' AS destination
81 ''; 81 '';
82 } 82 }
83 {
84 dest = "postfix/ldap_ejabberd_users_immae_fr";
85 user = config.services.postfix.user;
86 group = config.services.postfix.group;
87 permissions = "0440";
88 text = ''
89 server_host = ldaps://${config.myEnv.jabber.ldap.host}:636
90 search_base = ${config.myEnv.jabber.ldap.base}
91 query_filter = ${config.myEnv.jabber.postfix_user_filter}
92 domain = immae.fr
93 bind_dn = ${config.myEnv.jabber.ldap.dn}
94 bind_pw = ${config.myEnv.jabber.ldap.password}
95 result_attribute = immaeXmppUid
96 result_format = ejabberd@localhost
97 version = 3
98 '';
99 }
83 ]; 100 ];
84 101
85 networking.firewall.allowedTCPPorts = [ 25 465 587 ]; 102 networking.firewall.allowedTCPPorts = [ 25 465 587 ];
@@ -94,6 +111,7 @@
94 config.secrets.fullPaths."postfix/mysql_alias_maps" 111 config.secrets.fullPaths."postfix/mysql_alias_maps"
95 config.secrets.fullPaths."postfix/mysql_mailbox_maps" 112 config.secrets.fullPaths."postfix/mysql_mailbox_maps"
96 config.secrets.fullPaths."postfix/mysql_sender_login_maps" 113 config.secrets.fullPaths."postfix/mysql_sender_login_maps"
114 config.secrets.fullPaths."postfix/ldap_ejabberd_users_immae_fr"
97 ]; 115 ];
98 }; 116 };
99 services.postfix = { 117 services.postfix = {
@@ -161,7 +179,7 @@
161 virtual = pkgs.writeText "postfix-virtual" ( 179 virtual = pkgs.writeText "postfix-virtual" (
162 builtins.concatStringsSep "\n" ( 180 builtins.concatStringsSep "\n" (
163 lib.attrsets.mapAttrsToList ( 181 lib.attrsets.mapAttrsToList (
164 n: v: '' 182 n: v: lib.optionalString v.external ''
165 script_${n}@mail.immae.eu ${n}@localhost, scripts@mail.immae.eu 183 script_${n}@mail.immae.eu ${n}@localhost, scripts@mail.immae.eu
166 '' 184 ''
167 ) config.myEnv.mail.scripts 185 ) config.myEnv.mail.scripts
@@ -182,7 +200,7 @@
182 alias_database = "\$alias_maps"; 200 alias_database = "\$alias_maps";
183 201
184 ### Virtual mailboxes config 202 ### Virtual mailboxes config
185 virtual_alias_maps = "hash:/etc/postfix/virtual mysql:${config.secrets.fullPaths."postfix/mysql_alias_maps"}"; 203 virtual_alias_maps = "hash:/etc/postfix/virtual mysql:${config.secrets.fullPaths."postfix/mysql_alias_maps"} ldap:${config.secrets.fullPaths."postfix/ldap_ejabberd_users_immae_fr"}";
186 virtual_mailbox_domains = config.myEnv.mail.postfix.additional_mailbox_domains 204 virtual_mailbox_domains = config.myEnv.mail.postfix.additional_mailbox_domains
187 ++ lib.remove "localhost.immae.eu" (lib.remove null (lib.flatten (map 205 ++ lib.remove "localhost.immae.eu" (lib.remove null (lib.flatten (map
188 (zone: map 206 (zone: map