diff options
author | Alyssa Ross <hi@alyssa.is> | 2019-12-24 22:15:05 +0000 |
---|---|---|
committer | Alyssa Ross <hi@alyssa.is> | 2020-01-09 16:07:20 +0000 |
commit | ebc4ccc4cd8b3fb13023e328112733465db9253c (patch) | |
tree | 48ea4ef5d597947d7095617aa610d06cefb5a4b6 | |
parent | 576037d0ea38143331e91133c71f4f6f969240f7 (diff) | |
download | nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.tar nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.tar.gz nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.tar.bz2 nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.tar.lz nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.tar.xz nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.tar.zst nixlib-ebc4ccc4cd8b3fb13023e328112733465db9253c.zip |
spamassassin: use /etc/mail/spamassassin for config
Using a custom path in the Nix store meant that users of the module couldn't add their own config files, which is a desirable feature. I don't think avoiding /etc buys us anything.
3 files changed, 8 insertions, 37 deletions
diff --git a/nixpkgs/nixos/modules/services/mail/spamassassin.nix b/nixpkgs/nixos/modules/services/mail/spamassassin.nix index 1fe77ce5a0c7..71cdd5679dac 100644 --- a/nixpkgs/nixos/modules/services/mail/spamassassin.nix +++ b/nixpkgs/nixos/modules/services/mail/spamassassin.nix @@ -7,15 +7,6 @@ let spamassassin-local-cf = pkgs.writeText "local.cf" cfg.config; spamassassin-init-pre = pkgs.writeText "init.pre" cfg.initPreConf; - spamdEnv = pkgs.buildEnv { - name = "spamd-env"; - paths = []; - postBuild = '' - ln -sf ${spamassassin-init-pre} $out/init.pre - ln -sf ${spamassassin-local-cf} $out/local.cf - ''; - }; - in { @@ -120,13 +111,11 @@ in }; config = mkIf cfg.enable { + environment.etc."mail/spamassassin/init.pre".source = cfg.initPreConf; + environment.etc."mail/spamassassin/local.cf".source = spamassassin-local-cf; # Allow users to run 'spamc'. - - environment = { - etc = singleton { source = spamdEnv; target = "spamassassin"; }; - systemPackages = [ pkgs.spamassassin ]; - }; + environment.systemPackages = [ pkgs.spamassassin ]; users.users = singleton { name = "spamd"; @@ -143,7 +132,7 @@ in systemd.services.sa-update = { script = '' set +e - ${pkgs.su}/bin/su -s "${pkgs.bash}/bin/bash" -c "${pkgs.spamassassin}/bin/sa-update --gpghomedir=/var/lib/spamassassin/sa-update-keys/ --siteconfigpath=${spamdEnv}/" spamd + ${pkgs.su}/bin/su -s "${pkgs.bash}/bin/bash" -c "${pkgs.spamassassin}/bin/sa-update" --gpghomedir=/var/lib/spamassassin/sa-update-keys/ spamd v=$? set -e @@ -174,7 +163,7 @@ in after = [ "network.target" ]; serviceConfig = { - ExecStart = "${pkgs.spamassassin}/bin/spamd ${optionalString cfg.debug "-D"} --username=spamd --groupname=spamd --siteconfigpath=${spamdEnv} --virtual-config-dir=/var/lib/spamassassin/user-%u --allow-tell --pidfile=/run/spamd.pid"; + ExecStart = "${pkgs.spamassassin}/bin/spamd ${optionalString cfg.debug "-D"} --username=spamd --groupname=spamd --virtual-config-dir=/var/lib/spamassassin/user-%u --allow-tell --pidfile=/run/spamd.pid"; ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID"; }; @@ -185,7 +174,7 @@ in mkdir -p /var/lib/spamassassin chown spamd:spamd /var/lib/spamassassin -R set +e - ${pkgs.su}/bin/su -s "${pkgs.bash}/bin/bash" -c "${pkgs.spamassassin}/bin/sa-update --gpghomedir=/var/lib/spamassassin/sa-update-keys/ --siteconfigpath=${spamdEnv}/" spamd + ${pkgs.su}/bin/su -s "${pkgs.bash}/bin/bash" -c "${pkgs.spamassassin}/bin/sa-update --gpghomedir=/var/lib/spamassassin/sa-update-keys/" spamd v=$? set -e if [ $v -gt 1 ]; then diff --git a/nixpkgs/pkgs/servers/mail/spamassassin/default.nix b/nixpkgs/pkgs/servers/mail/spamassassin/default.nix index 186f4670153f..2ebbcf8e7866 100644 --- a/nixpkgs/pkgs/servers/mail/spamassassin/default.nix +++ b/nixpkgs/pkgs/servers/mail/spamassassin/default.nix @@ -9,9 +9,6 @@ perlPackages.buildPerlPackage rec { sha256 = "1np8h293bzg33i0xn9gj9krwgr7k6xbyf1yhxr2j2xci95d080yg"; }; - # https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7434 - patches = [ ./sa-update_add--siteconfigpath.patch ]; - buildInputs = [ makeWrapper ] ++ (with perlPackages; [ HTMLParser NetDNS NetAddrIP DBFile HTTPDate MailDKIM LWP IOSocketSSL DBI EncodeDetect IPCountry NetIdent Razor2ClientAgent MailSPF NetDNSResolverProgrammable ]); @@ -19,7 +16,7 @@ perlPackages.buildPerlPackage rec { # for the PERL5LIB environment variable. Needs further investigation. makeFlags = "PERL_BIN=${perlPackages.perl}/bin/perl PERL_TAINT=no"; - makeMakerFlags = "CONFDIR=/homeless/shelter LOCALSTATEDIR=/var/lib/spamassassin"; + makeMakerFlags = "SYSCONFDIR=/etc LOCALSTATEDIR=/var/lib/spamassassin"; doCheck = false; diff --git a/nixpkgs/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch b/nixpkgs/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch index 3264aefc0722..bac048892fe8 100644 --- a/nixpkgs/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch +++ b/nixpkgs/pkgs/servers/mail/spamassassin/sa-update_add--siteconfigpath.patch @@ -30,7 +30,7 @@ index bb7396d..39f681f 100755 # check only disabled gpg # https://issues.apache.org/SpamAssassin/show_bug.cgi?id=5854 -@@ -1808,6 +1812,7 @@ Options: +@@ -1808,7 +1812,7 @@ Options: --updatedir path Directory to place updates, defaults to the SpamAssassin site rules directory (default: @@LOCAL_STATE_DIR@@/@@VERSION@@) @@ -39,21 +39,6 @@ index bb7396d..39f681f 100755 -D, --debug [area=n,...] Print debugging messages -v, --verbose Be verbose, like print updated channel names; -- -diff --git a/lib/Mail/SpamAssassin/PerMsgStatus.pm b/lib/Mail/SpamAssassin/PerMsgStatus.pm -index 6d8beaa..6ad87dc 100644 ---- a/lib/Mail/SpamAssassin/PerMsgStatus.pm -+++ b/lib/Mail/SpamAssassin/PerMsgStatus.pm -@@ -389,7 +389,8 @@ sub check_timed { - if (!$self->{main}->have_plugin("check_main")) { - die "check: no loaded plugin implements 'check_main': cannot scan!\n". - "Check that the necessary '.pre' files are in the config directory.\n". -- "At a minimum, v320.pre loads the Check plugin which is required.\n"; -+ "At a minimum, v320.pre loads the Check plugin which is required.\n". -+ "NixOS: Since there is no '/etc/spamassassin' simply restart 'spamd.service' which on its behalf will run 'sa-learn --siteconfigpath=/nix/store/l4hr4yxk8mb4wbkha6vm6rh92pj19rj6-spamd-env ...' to update the /var/lib/spamassassin configs.\n"; - } - } - --- 2.12.2 |