nixos(spamassassin): provide /etc/spamassassin to fix sa-learn et al

Spamassassin expects its system-wide configuration at /etc/spamassassin, and
some user tools (like sa-learn) need to read those configuration files.
Therefore, we provide a symlink from /etc/spamassassin to the appropriate Nix
store path to make sure those tools work without the user having to pass an
elaborate --siteconfig path that, potentially, changes every time the system
updates.

Fixes https://github.com/NixOS/nixpkgs/issues/29414.
This commit is contained in:
Peter Simons 2017-09-27 14:34:47 +02:00
parent 3abee357e6
commit bfab392e6e

View File

@ -122,7 +122,11 @@ in
config = mkIf cfg.enable { config = mkIf cfg.enable {
# Allow users to run 'spamc'. # Allow users to run 'spamc'.
environment.systemPackages = [ pkgs.spamassassin ];
environment = {
etc = singleton { source = spamdEnv; target = "spamassassin"; };
systemPackages = [ pkgs.spamassassin ];
};
users.extraUsers = singleton { users.extraUsers = singleton {
name = "spamd"; name = "spamd";
@ -177,11 +181,6 @@ in
# 0 and 1 no error, exitcode > 1 means error: # 0 and 1 no error, exitcode > 1 means error:
# https://spamassassin.apache.org/full/3.1.x/doc/sa-update.html#exit_codes # https://spamassassin.apache.org/full/3.1.x/doc/sa-update.html#exit_codes
preStart = '' preStart = ''
# this abstraction requires no centralized config at all
if [ -d /etc/spamassassin ]; then
echo "This spamassassin does not support global '/etc/spamassassin' folder for configuration as this would be impure. Merge your configs into 'services.spamassassin' and remove the '/etc/spamassassin' folder to make this service work. Also see 'https://github.com/NixOS/nixpkgs/pull/26470'.";
exit 1
fi
echo "Recreating '/var/lib/spamasassin' with creating '3.004001' (or similar) and 'sa-update-keys'" echo "Recreating '/var/lib/spamasassin' with creating '3.004001' (or similar) and 'sa-update-keys'"
mkdir -p /var/lib/spamassassin mkdir -p /var/lib/spamassassin
chown spamd:spamd /var/lib/spamassassin -R chown spamd:spamd /var/lib/spamassassin -R