sieve: offload mailserver.loginAccounts.<name>.sieveScript into /nix/store
This simplifies the remaining structure of `cfg.sieveDirectory` a lot and gets us one step closer to removing `activate-virtual-mail-users.service`.
This commit is contained in:
+13
-1
@@ -346,7 +346,19 @@ in
|
||||
"sieve_script default" = {
|
||||
# declarative
|
||||
type = "default";
|
||||
path = "${cfg.sieveDirectory}/%{user}/default.sieve";
|
||||
name = "default";
|
||||
# TODO: Pre-compile Sieve scripts with 'sievec' (requires a Dovecot config in build sandbox)
|
||||
path = "${
|
||||
pkgs.runCommand "declarative-sieve-scripts" { } (
|
||||
''
|
||||
mkdir "$out"
|
||||
''
|
||||
+ lib.concatMapAttrsStringSep "\n" (_: value: ''
|
||||
mkdir "$out/${value.name}"
|
||||
cp -v "${builtins.toFile "default.sieve" value.sieveScript}" "$out/${value.name}/default.sieve"
|
||||
'') (lib.filterAttrs (_: value: value.sieveScript != null) cfg.accounts)
|
||||
)
|
||||
}/%{user}/default.sieve";
|
||||
};
|
||||
|
||||
"sieve_script personal" = {
|
||||
|
||||
@@ -41,33 +41,6 @@ let
|
||||
chown "${cfg.storage.owner}:${cfg.storage.group}" "${cfg.sieveDirectory}"
|
||||
chmod 770 "${cfg.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 "${cfg.sieveDirectory}/${name}"); then
|
||||
mkdir -p "${cfg.sieveDirectory}/${name}"
|
||||
chown "${cfg.storage.owner}:${cfg.storage.group}" "${cfg.sieveDirectory}/${name}"
|
||||
chmod 770 "${cfg.sieveDirectory}/${name}"
|
||||
fi
|
||||
cat << 'EOF' > "${cfg.sieveDirectory}/${name}/default.sieve"
|
||||
${sieveScript}
|
||||
EOF
|
||||
chown "${cfg.storage.owner}:${cfg.storage.group}" "${cfg.sieveDirectory}/${name}/default.sieve"
|
||||
''
|
||||
else
|
||||
''
|
||||
if (test -f "${cfg.sieveDirectory}/${name}/default.sieve"); then
|
||||
rm "${cfg.sieveDirectory}/${name}/default.sieve"
|
||||
fi
|
||||
if (test -f "${cfg.sieveDirectory}/${name}.svbin"); then
|
||||
rm "${cfg.sieveDirectory}/${name}/default.svbin"
|
||||
fi
|
||||
''
|
||||
) (map (user: { inherit (user) name sieveScript; }) (lib.attrValues cfg.accounts))}
|
||||
'';
|
||||
in
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user