summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-05-06 00:10:16 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2022-05-06 00:10:16 +0200
commite23823d812de7df0eb1c3f8c9df63956158802c6 (patch)
tree55b23c29b1f268c048473d8b65caeea02d4547c8
parentff566cb93a9b4ce63d5663328d99399da3a3ee5a (diff)
downloadnixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar.gz
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar.bz2
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.tar.xz
nixos-e23823d812de7df0eb1c3f8c9df63956158802c6.zip
surtr: ...
-rw-r--r--hosts/surtr/email/default.nix2
-rw-r--r--hosts/surtr/postgresql.nix13
2 files changed, 14 insertions, 1 deletions
diff --git a/hosts/surtr/email/default.nix b/hosts/surtr/email/default.nix
index aa901f6f..265207cc 100644
--- a/hosts/surtr/email/default.nix
+++ b/hosts/surtr/email/default.nix
@@ -349,7 +349,7 @@ in {
349 args = ${pkgs.writeText "dovecot-sql.conf" '' 349 args = ${pkgs.writeText "dovecot-sql.conf" ''
350 driver = pgsql 350 driver = pgsql
351 connect = dbname=email 351 connect = dbname=email
352 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) 352 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)
353 ''} 353 ''}
354 354
355 skip = never 355 skip = never
diff --git a/hosts/surtr/postgresql.nix b/hosts/surtr/postgresql.nix
index 28ccd8c4..0352c27f 100644
--- a/hosts/surtr/postgresql.nix
+++ b/hosts/surtr/postgresql.nix
@@ -60,10 +60,23 @@ in {
60 BEGIN; 60 BEGIN;
61 SELECT _v.register_patch('002-citext', ARRAY['000-base'], null); 61 SELECT _v.register_patch('002-citext', ARRAY['000-base'], null);
62 62
63 DROP VIEW virtual_mailbox_domain;
64 DROP VIEW virtual_mailbox_mapping;
65 DROP VIEW imap_user;
66 DROP VIWE lmtp_mapping;
67
63 CREATE EXTENSION citext; 68 CREATE EXTENSION citext;
69
64 ALTER TABLE mailbox ALTER mailbox TYPE citext; 70 ALTER TABLE mailbox ALTER mailbox TYPE citext;
65 ALTER TABLE mailbox_mapping ALTER local TYPE citext; 71 ALTER TABLE mailbox_mapping ALTER local TYPE citext;
66 ALTER TABLE mailbox_mapping ALTER domain TYPE citext; 72 ALTER TABLE mailbox_mapping ALTER domain TYPE citext;
73
74 CREATE VIEW mailbox_quote_rule (id, mailbox, quota_rule) AS SELECT id, mailbox, (CASE WHEN quota_bytes IS NULL THEN '*:ignore' ELSE '*:bytes=' || quota_bytes END) AS quota_rule FROM mailbox;
75
76 CREATE VIEW virtual_mailbox_domain (domain) AS SELECT DISTINCT domain FROM mailbox_mapping;
77 CREATE VIEW virtual_mailbox_mapping (lookup) AS SELECT (CASE WHEN local IS NULL THEN ''' ELSE local END) || '@' || domain AS lookup FROM mailbox_mapping;
78 CREATE VIEW imap_user ("user", quota_rule) AS SELECT mailbox AS "user", quota_rule FROM mailbox_quota_rule;
79 CREATE VIEW lmtp_mapping ("user", quota_rule, local, domain) AS SELECT mailbox_quota_rule.mailbox AS "user", quota_rule, local, domain FROM mailbox_quota_rule INNER JOIN mailbox_mapping ON mailbox_quota_rule.id = mailbox_mapping.mailbox;
67 COMMIT; 80 COMMIT;
68 ''} 81 ''}
69 ''; 82 '';