dovecot: the imap_sieve plugin doesn't work anymore in nixos. need a fast solution.

This commit is contained in:
Daniel Frank 2025-07-04 20:39:44 +02:00
commit e7955cab65
Signed by: tokudan
GPG key ID: 9282F413EDB72E05
9 changed files with 1 additions and 117 deletions

View file

@ -70,7 +70,7 @@ let
}
protocol imap {
mail_plugins = $mail_plugins imap_sieve
mail_plugins = $mail_plugins
}
imap_idle_notify_interval = 29 mins
@ -99,22 +99,6 @@ let
}
prefix =
}
plugin {
sieve_after = ${(pkgs.callPackage ./sieve-after.nix {}) }
sieve_plugins = sieve_imapsieve sieve_extprograms
# From elsewhere to Spam folder
imapsieve_mailbox1_name = Junk
imapsieve_mailbox1_causes = COPY
imapsieve_mailbox1_before = file:${(pkgs.callPackage ./sieve-report-spam-ham.nix {})}/report-spam.sieve
# From Spam folder to elsewhere
imapsieve_mailbox2_name = *
imapsieve_mailbox2_from = Junk
imapsieve_mailbox2_causes = COPY
imapsieve_mailbox2_before = file:${(pkgs.callPackage ./sieve-report-spam-ham.nix {})}/report-ham.sieve
sieve_pipe_bin_dir = ${(pkgs.callPackage ./sieve-pipe-bin-dir.nix {})}
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
}
'';
in
{

View file

@ -1,20 +0,0 @@
{ stdenv, dovecot_pigeonhole}:
stdenv.mkDerivation rec {
name = "sieve-after";
src = ./sieve-after;
phases = [ "copyPhase" "compilePhase" ];
copyPhase = ''
cd $src
mkdir $out
cp -Rv $src/. $out/
find $out -type d -exec chmod -c 0755 {} \;
set +x
'';
compilePhase = ''
find $out -iname '*.sieve' -print0 | xargs -t -0 -n1 ${dovecot_pigeonhole}/bin/sievec -c /dev/null
'';
}

View file

@ -1,6 +0,0 @@
require ["fileinto","mailbox"];
if header :contains "X-Spam" "Yes" {
fileinto :create "Junk";
stop;
}

View file

@ -1,14 +0,0 @@
{ stdenv}:
stdenv.mkDerivation rec {
name = "sieve-pipe-bin-dir";
src = ./sieve-pipe-bin-dir;
phases = [ "copyPhase" "fixupPhase" ];
copyPhase = ''
mkdir $out
cp -Rv $src/. $out/
'';
}

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
exec /run/current-system/sw/bin/rspamc -h /run/rspamd/worker-controller.socket learn_ham

View file

@ -1,4 +0,0 @@
#!/usr/bin/env bash
set -euo pipefail
exec /run/current-system/sw/bin/rspamc -h /run/rspamd/worker-controller.socket learn_spam

View file

@ -1,30 +0,0 @@
{ stdenv, dovecot_pigeonhole}:
stdenv.mkDerivation rec {
name = "sieve-report-spam-ham";
src = ./sieve-report-spam-ham;
phases = [ "copyPhase" "compilePhase" ];
copyPhase = ''
mkdir $out
cp -Rv $src/. $out/
find $out -type d -exec chmod -c 0755 {} \;
set +x
'';
# Yeah, need a specific dovecot.conf to enable the necessary plugins...
# taking the one used by the dovecot that actually executes the sieve scripts should
# work as well, but passing it through isn't worth my time.
compilePhase = ''
dc=$(pwd)/dovecot.conf
cat > $dc <<-EOF
plugin {
sieve_plugins = sieve_imapsieve sieve_extprograms
sieve_global_extensions = +vnd.dovecot.pipe +vnd.dovecot.environment
}
EOF
find $out -iname '*.sieve' -print0 | xargs -t -0 -n1 ${dovecot_pigeonhole}/bin/sievec -c $dc
'';
}

View file

@ -1,15 +0,0 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.mailbox" "*" {
set "mailbox" "${1}";
}
if string "${mailbox}" "Trash" {
stop;
}
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "learn-ham.sh" [ "${username}" ];

View file

@ -1,7 +0,0 @@
require ["vnd.dovecot.pipe", "copy", "imapsieve", "environment", "variables"];
if environment :matches "imap.user" "*" {
set "username" "${1}";
}
pipe :copy "learn-spam.sh" [ "${username}" ];