diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index 34c94fb..731b578 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -110,6 +110,8 @@ in plugin { sieve = file:/var/sieve/%u/scripts;active=/var/sieve/%u/active.sieve + sieve_default = file:/var/sieve/%u/default.sieve + sieve_default_name = default } lda_mailbox_autosubscribe = yes diff --git a/mail-server/users.nix b/mail-server/users.nix index 9484882..a8cda32 100644 --- a/mail-server/users.nix +++ b/mail-server/users.nix @@ -55,16 +55,21 @@ let # is null, remove the file. ${lib.concatMapStringsSep "\n" ({ name, sieveScript }: if lib.isString sieveScript then '' - cat << EOF > "/var/sieve/${name}.sieve" + if (! test -d "/var/sieve/${name}"); then + mkdir -p "/var/sieve/${name}" + chown "${name}:${vmailGroupName}" "/var/sieve/${name}" + chmod 770 "/var/sieve/${name}" + fi + cat << EOF > "/var/sieve/${name}/default.sieve" ${sieveScript} EOF - chown "${name}:${vmailGroupName}" "/var/sieve/${name}.sieve" + chown "${name}:${vmailGroupName}" "/var/sieve/${name}/default.sieve" '' else '' - if (test -f "/var/sieve/${name}.sieve"); then - rm "/var/sieve/${name}.sieve" + if (test -f "/var/sieve/${name}/default.sieve"); then + rm "/var/sieve/${name}/default.sieve" fi if (test -f "/var/sieve/${name}.svbin"); then - rm "/var/sieve/${name}.svbin" + rm "/var/sieve/${name}/default.svbin" fi '') (map (user: { inherit (user) name sieveScript; }) (lib.attrValues loginAccounts))}