diff --git a/default.nix b/default.nix index b5c4799..5ebb391 100644 --- a/default.nix +++ b/default.nix @@ -452,6 +452,14 @@ in ''; }; + sieveDirectory = mkOption { + type = types.path; + default = "/var/sieve"; + description = '' + Where to store the sieve scripts. + ''; + }; + virusScanning = mkOption { type = types.bool; default = false; diff --git a/mail-server/dovecot.nix b/mail-server/dovecot.nix index 4e77baf..23609fe 100644 --- a/mail-server/dovecot.nix +++ b/mail-server/dovecot.nix @@ -217,8 +217,8 @@ in plugin { sieve_plugins = sieve_imapsieve sieve_extprograms - sieve = file:/var/sieve/%u/scripts;active=/var/sieve/%u/active.sieve - sieve_default = file:/var/sieve/%u/default.sieve + 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 diff --git a/mail-server/users.nix b/mail-server/users.nix index 3ab31d5..0b168c1 100644 --- a/mail-server/users.nix +++ b/mail-server/users.nix @@ -35,31 +35,31 @@ let set -euo pipefail # Create directory to store user sieve scripts if it doesn't exist - if (! test -d "/var/sieve"); then - mkdir "/var/sieve" - chown "${vmailUserName}:${vmailGroupName}" "/var/sieve" - chmod 770 "/var/sieve" + if (! test -d "${sieveDirectory}"); then + mkdir "${sieveDirectory}" + chown "${vmailUserName}:${vmailGroupName}" "${sieveDirectory}" + chmod 770 "${sieveDirectory}" fi # Copy user's sieve script to the correct location (if it exists). If it # is null, remove the file. ${lib.concatMapStringsSep "\n" ({ name, sieveScript }: if lib.isString sieveScript then '' - if (! test -d "/var/sieve/${name}"); then - mkdir -p "/var/sieve/${name}" - chown "${vmailUserName}:${vmailGroupName}" "/var/sieve/${name}" - chmod 770 "/var/sieve/${name}" + if (! test -d "${sieveDirectory}/${name}"); then + mkdir -p "${sieveDirectory}/${name}" + chown "${vmailUserName}:${vmailGroupName}" "${sieveDirectory}/${name}" + chmod 770 "${sieveDirectory}/${name}" fi - cat << 'EOF' > "/var/sieve/${name}/default.sieve" + cat << 'EOF' > "${sieveDirectory}/${name}/default.sieve" ${sieveScript} EOF - chown "${vmailUserName}:${vmailGroupName}" "/var/sieve/${name}/default.sieve" + chown "${vmailUserName}:${vmailGroupName}" "${sieveDirectory}/${name}/default.sieve" '' else '' - if (test -f "/var/sieve/${name}/default.sieve"); then - rm "/var/sieve/${name}/default.sieve" + if (test -f "${sieveDirectory}/${name}/default.sieve"); then + rm "${sieveDirectory}/${name}/default.sieve" fi - if (test -f "/var/sieve/${name}.svbin"); then - rm "/var/sieve/${name}/default.svbin" + if (test -f "${sieveDirectory}/${name}.svbin"); then + rm "${sieveDirectory}/${name}/default.svbin" fi '') (map (user: { inherit (user) name sieveScript; }) (lib.attrValues loginAccounts))}