git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commitbfab392e6edf20be2cfa8a457a65c2e6b4cfedc2 authorPeter Simons <simons@cryp.to> dateWed 27 Sep 2017, 14:34 (9 years ago) parent3abee35
1 file changed+5−6
nixos/modules/services/mail/spamassassin.nix+5−6
nixos/modules/services/mail/spamassassin.nix+5−6
@@ -122,7 +122,11 @@ in
122122 config = mkIf cfg.enable {
123123
124124 # Allow users to run 'spamc'.
125− environment.systemPackages = [ pkgs.spamassassin ];
125+
126+ environment = {
127+ etc = singleton { source = spamdEnv; target = "spamassassin"; };
128+ systemPackages = [ pkgs.spamassassin ];
129+ };
126130
127131 users.extraUsers = singleton {
128132 name = "spamd";
@@ -177,11 +181,6 @@ in
177181 # 0 and 1 no error, exitcode > 1 means error:
178182 # https://spamassassin.apache.org/full/3.1.x/doc/sa-update.html#exit_codes
179183 preStart = ''
180− # this abstraction requires no centralized config at all
181− if [ -d /etc/spamassassin ]; then
182− 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'.";
183− exit 1
184− fi
185184 echo "Recreating '/var/lib/spamasassin' with creating '3.004001' (or similar) and 'sa-update-keys'"
186185 mkdir -p /var/lib/spamassassin
187186 chown spamd:spamd /var/lib/spamassassin -R