From bb9860c49f37d8e0b08275e2ad6762f36219e918 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Thu, 5 May 2022 22:02:25 +0200 Subject: surtr: ... --- hosts/surtr/email/default.nix | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) (limited to 'hosts/surtr/email') diff --git a/hosts/surtr/email/default.nix b/hosts/surtr/email/default.nix index a6fbcaf3..f4543bf4 100644 --- a/hosts/surtr/email/default.nix +++ b/hosts/surtr/email/default.nix @@ -137,11 +137,13 @@ in { recipient_canonical_classes = ["envelope_recipient" "header_recipient"]; virtual_mailbox_domains = ''pgsql:${pkgs.writeText "virtual_mailbox_domains.cf" '' - hosts = postgresql://localhost/emails + hosts = postgresql://localhost + dbname = emails query = SELECT domain FROM virtual_mailbox_domain WHERE domain = '%s' ''}''; virtual_mailbox_maps = ''pgsql:${pkgs.writeText "virtual_mailbox_maps.cf" '' - hosts = postgresql://localhost/emails + hosts = postgresql://localhost + dbname = emails query = SELECT mailbox FROM virtual_mailbox_mapping WHERE mailbox = '%s' ''}''; virtual_transport = "lmtp:unix:/run/postfix/dovecot-lmtp"; @@ -280,7 +282,14 @@ in { mailLocation = "maildir:/var/lib/mail/%u/maildir:UTF-8"; modules = with pkgs; [ dovecot_pigeonhole ]; protocols = [ "lmtp" "sieve" ]; - extraConfig = '' + extraConfig = let + dovecotSqlConf = pkgs.writeText "dovecot-sql.conf" '' + driver = pgsql + connect = dbname=email + password_query = SELECT user, quota_rule FROM imap_user WHERE user = '%u' + user_query = SELECT user, quota_rule FROM imap_user WHERE user = '%u' + ''; + in '' mail_home = /var/lib/mail/%u local_name imap.bouncy.email { @@ -306,11 +315,12 @@ in { userdb { driver = sql - args = ${pkgs.writeText "dovecot-sql.conf" '' - driver = pgsql - connect = dbname=email - user_query = SELECT user, quota_rule FROM imap_user WHERE user = '%u' - ''} + args = ${dovecotSqlConf} + default_fields = uid=dovecot2 gid=dovecot2 nopassword + } + passdb { + driver = sql + args = ${dovecotSqlConf} default_fields = uid=dovecot2 gid=dovecot2 nopassword } -- cgit v1.2.3