dovecot: the imap_sieve plugin doesn't work anymore in nixos. need a fast solution.
This commit is contained in:
parent
774745a41a
commit
e7955cab65
9 changed files with 1 additions and 117 deletions
nixos-mailserver
dovecot.nixsieve-after.nix
sieve-after
sieve-pipe-bin-dir.nixsieve-pipe-bin-dir
sieve-report-spam-ham.nixsieve-report-spam-ham
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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
|
||||
'';
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
require ["fileinto","mailbox"];
|
||||
|
||||
if header :contains "X-Spam" "Yes" {
|
||||
fileinto :create "Junk";
|
||||
stop;
|
||||
}
|
|
@ -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/
|
||||
'';
|
||||
}
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
'';
|
||||
}
|
|
@ -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}" ];
|
|
@ -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}" ];
|
Loading…
Add table
Add a link
Reference in a new issue