From: Ismaƫl Bouya Date: Thu, 26 Dec 2019 17:55:50 +0000 (+0100) Subject: Add xmpp-mail bridge X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;ds=sidebyside;h=5b53d86f38bd8e42695a62be9a833beb66bbbba3;hp=106b1198698056047f5f18e627ba58b9aaec70f4;p=perso%2FImmae%2FConfig%2FNix.git Add xmpp-mail bridge --- 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 description = "Jabber configuration"; type = submodule { options = { + postfix_user_filter = mkOption { type = str; description = "Postfix filter to get xmpp users"; }; ldap = mkLdapOptions "Jabber" {}; postgresql = mkPsqlOptions "Jabber"; }; @@ -593,6 +594,7 @@ in description = "Mail script recipients"; type = attrsOf (submodule { options = { + external = mkEnableOption "Create a script_@mail.immae.eu external address"; src = mkOption { description = '' 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 @@ UNION SELECT '%s' AS destination ''; } + { + dest = "postfix/ldap_ejabberd_users_immae_fr"; + user = config.services.postfix.user; + group = config.services.postfix.group; + permissions = "0440"; + text = '' + server_host = ldaps://${config.myEnv.jabber.ldap.host}:636 + search_base = ${config.myEnv.jabber.ldap.base} + query_filter = ${config.myEnv.jabber.postfix_user_filter} + domain = immae.fr + bind_dn = ${config.myEnv.jabber.ldap.dn} + bind_pw = ${config.myEnv.jabber.ldap.password} + result_attribute = immaeXmppUid + result_format = ejabberd@localhost + version = 3 + ''; + } ]; networking.firewall.allowedTCPPorts = [ 25 465 587 ]; @@ -94,6 +111,7 @@ config.secrets.fullPaths."postfix/mysql_alias_maps" config.secrets.fullPaths."postfix/mysql_mailbox_maps" config.secrets.fullPaths."postfix/mysql_sender_login_maps" + config.secrets.fullPaths."postfix/ldap_ejabberd_users_immae_fr" ]; }; services.postfix = { @@ -161,7 +179,7 @@ virtual = pkgs.writeText "postfix-virtual" ( builtins.concatStringsSep "\n" ( lib.attrsets.mapAttrsToList ( - n: v: '' + n: v: lib.optionalString v.external '' script_${n}@mail.immae.eu ${n}@localhost, scripts@mail.immae.eu '' ) config.myEnv.mail.scripts @@ -182,7 +200,7 @@ alias_database = "\$alias_maps"; ### Virtual mailboxes config - virtual_alias_maps = "hash:/etc/postfix/virtual mysql:${config.secrets.fullPaths."postfix/mysql_alias_maps"}"; + 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"}"; virtual_mailbox_domains = config.myEnv.mail.postfix.additional_mailbox_domains ++ lib.remove "localhost.immae.eu" (lib.remove null (lib.flatten (map (zone: map