2014-04-14 15:26:48 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
2012-08-03 14:11:28 +01:00
|
|
|
|
2014-04-14 15:26:48 +01:00
|
|
|
with lib;
|
2012-08-03 14:11:28 +01:00
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.spamassassin;
|
|
|
|
|
|
|
|
in
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
###### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
|
|
|
|
services.spamassassin = {
|
|
|
|
|
|
|
|
enable = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to run the SpamAssassin daemon.";
|
|
|
|
};
|
|
|
|
|
2012-09-27 16:12:25 +01:00
|
|
|
debug = mkOption {
|
|
|
|
default = false;
|
|
|
|
description = "Whether to run the SpamAssassin daemon in debug mode.";
|
|
|
|
};
|
|
|
|
|
2012-08-03 14:11:28 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
###### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
|
2012-08-03 17:07:06 +01:00
|
|
|
# Allow users to run 'spamc'.
|
2012-08-03 14:11:28 +01:00
|
|
|
environment.systemPackages = [ pkgs.spamassassin ];
|
|
|
|
|
2012-09-27 23:06:52 +01:00
|
|
|
users.extraUsers = singleton {
|
|
|
|
name = "spamd";
|
|
|
|
description = "Spam Assassin Daemon";
|
|
|
|
uid = config.ids.uids.spamd;
|
|
|
|
group = "spamd";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.extraGroups = singleton {
|
|
|
|
name = "spamd";
|
|
|
|
gid = config.ids.gids.spamd;
|
|
|
|
};
|
2012-08-28 15:27:28 +01:00
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
systemd.services.spamd = {
|
2012-08-03 14:11:28 +01:00
|
|
|
description = "Spam Assassin Server";
|
2013-01-24 17:34:13 +00:00
|
|
|
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
after = [ "network.target" ];
|
|
|
|
|
2016-01-06 06:50:18 +00:00
|
|
|
script = "${pkgs.spamassassin}/bin/spamd ${optionalString cfg.debug "-D"} --username=spamd --groupname=spamd --nouser-config --virtual-config-dir=/var/lib/spamassassin/user-%u --allow-tell --pidfile=/var/run/spamd.pid";
|
2012-08-03 14:11:28 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|