From fe6d325397f35eecb51bc77d04cc1a805c98e249 Mon Sep 17 00:00:00 2001 From: Raito Bezarius Date: Sun, 14 Jan 2024 20:55:20 +0100 Subject: [PATCH] dovecot: support new `sieve` API in nixpkgs Since https://github.com/NixOS/nixpkgs/pull/275031 things have became more structured when it comes to the sieve plugin. Relies on https://github.com/NixOS/nixpkgs/pull/281001 for full features. --- mail-server/dovecot.nix | 54 +++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 24 deletions(-) diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index 7d73ee2..45c9d41 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -175,8 +175,18 @@ in mailPlugins.globally.enable = lib.optionals cfg.fullTextSearch.enable [ "fts" "fts_xapian" ]; protocols = lib.optional cfg.enableManageSieve "sieve"; - sieveScripts = { - after = builtins.toFile "spam.sieve" '' + pluginSettings = { + sieve = "file:${cfg.sieveDirectory}/%u/scripts;active=${cfg.sieveDirectory}/%u/active.sieve"; + sieve_default = "file:${cfg.sieveDirectory}/%u/default.sieve"; + sieve_default_name = "default"; + }; + + sieve = { + extensions = [ + "fileinto" + ]; + + scripts.after = builtins.toFile "spam.sieve" '' require "fileinto"; if header :is "X-Spam" "Yes" { @@ -184,8 +194,26 @@ in stop; } ''; + + pipeBins = [ + pipeBin + ]; }; + imapsieve.mailbox = [ + { + name = junkMailboxName; + causes = [ "COPY" "APPEND" ]; + before = "${stateDir}/imap_sieve/report-spam.sieve"; + } + { + name = "*"; + from = junkMailboxName; + causes = [ "COPY" ]; + before = "${stateDir}/imap_sieve/report-ham.sieve"; + } + ]; + mailboxes = cfg.mailboxes; extraConfig = '' @@ -307,28 +335,6 @@ in inbox = yes } - plugin { - sieve_plugins = sieve_imapsieve sieve_extprograms - sieve = file:${cfg.sieveDirectory}/%u/scripts;active=${cfg.sieveDirectory}/%u/active.sieve - sieve_default = file:${cfg.sieveDirectory}/%u/default.sieve - sieve_default_name = default - - # From elsewhere to Spam folder - imapsieve_mailbox1_name = ${junkMailboxName} - imapsieve_mailbox1_causes = COPY,APPEND - imapsieve_mailbox1_before = file:${stateDir}/imap_sieve/report-spam.sieve - - # From Spam folder to elsewhere - imapsieve_mailbox2_name = * - imapsieve_mailbox2_from = ${junkMailboxName} - imapsieve_mailbox2_causes = COPY - imapsieve_mailbox2_before = file:${stateDir}/imap_sieve/report-ham.sieve - - sieve_pipe_bin_dir = ${pipeBin}/pipe/bin - - sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment - } - ${lib.optionalString cfg.fullTextSearch.enable '' plugin { plugin = fts fts_xapian