nixos-config/packages/sievec.nix

35 lines
704 B
Nix
Raw Normal View History

2022-06-12 15:39:15 +00:00
{
writeText,
stdenv,
dovecot_pigeonhole,
...
} @ pkgs: {
name,
src,
exts,
}: let
dummyConfig = writeText "dovecot.cfg" ''
plugin {
sieve_plugins = sieve_imapsieve sieve_extprograms
sieve_global_extensions = +vnd.dovecot.pipe
}
'';
2022-01-20 16:02:42 +00:00
in
2022-06-12 15:39:15 +00:00
stdenv.mkDerivation {
inherit name;
inherit src;
2022-01-20 16:02:42 +00:00
2022-06-12 15:39:15 +00:00
phases = ["copyPhase" "compilePhase"];
2022-01-20 16:02:42 +00:00
2022-06-12 15:39:15 +00:00
copyPhase = ''
mkdir $out
cp $src $out/${name}.sieve
sed -i 's|/nix/store/||g' $out/${name}.sieve
chmod 0755 $out/${name}.sieve
set +x
'';
compilePhase = ''
${dovecot_pigeonhole}/bin/sievec -c ${dummyConfig} $out/${name}.sieve $out/${name}.svbin -x "${toString exts}"
'';
}