From 6671651e8bcb7a4f6e887ab3fbc1af8794946e29 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Fri, 15 May 2026 22:48:37 +0200 Subject: surtr: dovecot 2.4 --- hosts/surtr/email/default.nix | 368 ++++++++++++++++++++---------------------- 1 file changed, 179 insertions(+), 189 deletions(-) (limited to 'hosts/surtr/email') diff --git a/hosts/surtr/email/default.nix b/hosts/surtr/email/default.nix index 4243366c..e688f7d2 100644 --- a/hosts/surtr/email/default.nix +++ b/hosts/surtr/email/default.nix @@ -291,7 +291,7 @@ in { virtual_transport = "dvlmtp:unix:/run/dovecot-lmtp"; smtputf8_enable = false; - authorized_submit_users = "inline:{ root= postfwd= ${config.services.dovecot2.user}= }"; + authorized_submit_users = "inline:{ root= postfwd= ${config.services.dovecot2.settings.mail_uid}= }"; authorized_flush_users = "inline:{ root= }"; authorized_mailq_users = "inline:{ root= }"; @@ -528,215 +528,211 @@ in { }; }; - users.groups.${config.services.rspamd.group}.members = [ config.services.postfix.user config.services.dovecot2.user ]; + users.groups.${config.services.rspamd.group}.members = [ config.services.postfix.user config.services.dovecot2.settings.mail_uid ]; services.redis.servers.rspamd.enable = true; users.groups.${config.services.redis.servers.rspamd.user}.members = [ config.services.rspamd.user ]; - environment.systemPackages = with pkgs; [ dovecot_pigeonhole dovecot-fts-flatcurve ]; + environment.systemPackages = with pkgs; [ dovecot_pigeonhole ]; services.dovecot2 = { + package = pkgs.dovecot; enable = true; enablePAM = false; - sslServerCert = "/run/credentials/dovecot.service/surtr.yggdrasil.li.pem"; - sslServerKey = "/run/credentials/dovecot.service/surtr.yggdrasil.li.key.pem"; - sslCACert = toString ./ca/ca.crt; - mailLocation = "maildir:/var/lib/mail/%u/maildir:UTF-8:INDEX=/var/lib/dovecot/indices/%u"; - mailPlugins.globally.enable = [ "fts" "fts_flatcurve" ]; - protocols = [ "lmtp" "sieve" ]; - sieve = { - extensions = ["copy" "imapsieve" "variables" "imap4flags" "vacation" "vacation-seconds" "vnd.dovecot.debug"]; - globalExtensions = ["copy" "imapsieve" "variables" "imap4flags" "vacation" "vacation-seconds" "vnd.dovecot.debug"]; - }; - extraConfig = let - dovecotSqlConf = pkgs.writeText "dovecot-sql.conf" '' - driver = pgsql - connect = dbname=email - password_query = SELECT (CASE WHEN '%k' = 'valid' AND '%m' = 'EXTERNAL' THEN NULL ELSE "password" END) as password, (CASE WHEN '%k' = 'valid' AND '%m' = 'EXTERNAL' THEN true WHEN password IS NULL THEN true ELSE NULL END) as nopassword, "user", quota_rule, '${config.services.dovecot2.user}' as uid, '${config.services.dovecot2.group}' as gid FROM imap_user WHERE "user" = '%n' - user_query = SELECT "user", quota_rule, '${config.services.dovecot2.user}' as uid, 'dovecot2' as gid FROM imap_user WHERE "user" = '%n' - iterate_query = SELECT "user" FROM imap_user - ''; - in '' - mail_home = /var/lib/mail/%u - - mail_plugins = $mail_plugins quota fts fts_flatcurve - - first_valid_uid = ${toString config.users.users.${config.services.dovecot2.user}.uid} - last_valid_uid = ${toString config.users.users.${config.services.dovecot2.user}.uid} - first_valid_gid = ${toString config.users.groups.${config.services.dovecot2.group}.gid} - last_valid_gid = ${toString config.users.groups.${config.services.dovecot2.group}.gid} - - ${concatMapStringsSep "\n\n" (domain: - concatMapStringsSep "\n" (subdomain: '' - local_name ${subdomain} { - ssl_cert =