summaryrefslogtreecommitdiff
path: root/hosts/surtr
diff options
context:
space:
mode:
Diffstat (limited to 'hosts/surtr')
-rw-r--r--hosts/surtr/email/default.nix20
-rw-r--r--hosts/surtr/postgresql.nix6
2 files changed, 21 insertions, 5 deletions
diff --git a/hosts/surtr/email/default.nix b/hosts/surtr/email/default.nix
index 8889991c..b3306ece 100644
--- a/hosts/surtr/email/default.nix
+++ b/hosts/surtr/email/default.nix
@@ -146,11 +146,6 @@ in {
146 dbname = email 146 dbname = email
147 query = SELECT 1 FROM virtual_mailbox_mapping WHERE lookup = '%s' 147 query = SELECT 1 FROM virtual_mailbox_mapping WHERE lookup = '%s'
148 ''}''; 148 ''}'';
149 lmtp_generic_maps = ''pgsql:${pkgs.writeText "virtual_mailbox_maps.cf" ''
150 hosts = postgresql:///email
151 dbname = email
152 query = SELECT mailbox FROM virtual_mailbox_mapping WHERE lookup = '%s'
153 ''}'';
154 virtual_transport = "lmtp:unix:/run/postfix/dovecot-lmtp"; 149 virtual_transport = "lmtp:unix:/run/postfix/dovecot-lmtp";
155 }; 150 };
156 masterConfig = { 151 masterConfig = {
@@ -349,6 +344,21 @@ in {
349 args = ${dovecotSqlConf} 344 args = ${dovecotSqlConf}
350 } 345 }
351 346
347 protocol lmtp {
348 userdb {
349 driver = sql
350 args = ${pkgs.writeText "dovecot-sql.conf" ''
351 driver = pgsql
352 connect = dbname=email
353 user_query = SELECT DISTINCT ON (local IS NULL) "user", quota_rule, 'dovecot2' as uid, 'dovecot2' as gid FROM lmtp_mapping WHERE (local = '%n' AND domain = '%d') OR (local IS NULL AND domain = '%d') ORDER BY (local IS NULL ASC)
354 ''}
355
356 skip = never
357 result_failure = return-fail
358 result_internalfail = return-fail
359 }
360 }
361
352 mail_plugins = $mail_plugins quota 362 mail_plugins = $mail_plugins quota
353 mailbox_list_index = yes 363 mailbox_list_index = yes
354 postmaster_address = postmaster@yggdrasil.li 364 postmaster_address = postmaster@yggdrasil.li
diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix
index c1993431..4899b972 100644
--- a/hosts/surtr/postgresql.nix
+++ b/hosts/surtr/postgresql.nix
@@ -50,6 +50,12 @@ in {
50 50
51 CREATE VIEW imap_user ("user", quota_rule) AS SELECT mailbox AS "user", (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) AS quota_rule FROM mailbox; 51 CREATE VIEW imap_user ("user", quota_rule) AS SELECT mailbox AS "user", (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) AS quota_rule FROM mailbox;
52 COMMIT; 52 COMMIT;
53
54 BEGIN;
55 SELECT _v.register_patch('001-lmtp-mapping', ARRAY['000-base'], null);
56
57 CREATE VIEW lmtp_mapping ("user", quota_rule, local, domain) AS SELECT mailbox.mailbox AS "user", (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) AS quota_rule FROM mailbox INNER JOIN mailbox_mapping ON mailbox.id = mailbox_mapping.mailbox;
58 COMMIT;
53 ''} 59 ''}
54 ''; 60 '';
55 }; 61 };