From b781cf1a12ce77fd29ec0656bb04895b0cdaecf7 Mon Sep 17 00:00:00 2001 From: Nikolay Amiantov Date: Sun, 10 Jan 2016 07:05:12 +0300 Subject: nixos/dovecot: add sieveScripts support --- nixos/modules/services/mail/dovecot.nix | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'nixos') diff --git a/nixos/modules/services/mail/dovecot.nix b/nixos/modules/services/mail/dovecot.nix index a2a93a520e9b..efe6a3beb9ae 100644 --- a/nixos/modules/services/mail/dovecot.nix +++ b/nixos/modules/services/mail/dovecot.nix @@ -51,6 +51,12 @@ let } '') + (optionalString (cfg.sieveScripts != {}) '' + plugin { + ${concatStringsSep "\n" (mapAttrsToList (to: from: "sieve_${to} = ${stateDir}/sieve/${to}") cfg.sieveScripts)} + } + '') + cfg.extraConfig ]; @@ -165,6 +171,12 @@ in description = "Whether to create a own Dovecot PAM service and configure PAM user logins."; }; + sieveScripts = mkOption { + type = types.attrsOf types.path; + default = {}; + description = "Sieve scripts to be executed. Key is a sequence, e.g. 'before2', 'after' etc."; + }; + showPAMFailure = mkOption { type = types.bool; default = false; @@ -219,6 +231,22 @@ in StartLimitInterval = "1min"; RuntimeDirectory = [ "dovecot2" ]; }; + + preStart = '' + rm -rf ${stateDir}/sieve + '' + optionalString (cfg.sieveScripts != {}) '' + mkdir -p ${stateDir}/sieve + ${concatStringsSep "\n" (mapAttrsToList (to: from: '' + if [ -d '${from}' ]; then + mkdir '${stateDir}/sieve/${to}' + cp ${from}/*.sieve '${stateDir}/sieve/${to}' + else + cp '${from}' '${stateDir}/sieve/${to}' + fi + ${pkgs.dovecot_pigeonhole}/bin/sievec '${stateDir}/sieve/${to}' + '') cfg.sieveScripts)} + chown -R '${cfg.user}:${cfg.group}' ${stateDir}/sieve + ''; }; environment.systemPackages = [ dovecotPkg ]; -- cgit 1.4.1