at 16.09-beta 1.2 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4 5let 6 7 cfg = config.services.spamassassin; 8 9in 10 11{ 12 13 ###### interface 14 15 options = { 16 17 services.spamassassin = { 18 19 enable = mkOption { 20 default = false; 21 description = "Whether to run the SpamAssassin daemon."; 22 }; 23 24 debug = mkOption { 25 default = false; 26 description = "Whether to run the SpamAssassin daemon in debug mode."; 27 }; 28 29 }; 30 31 }; 32 33 34 ###### implementation 35 36 config = mkIf cfg.enable { 37 38 # Allow users to run 'spamc'. 39 environment.systemPackages = [ pkgs.spamassassin ]; 40 41 users.extraUsers = singleton { 42 name = "spamd"; 43 description = "Spam Assassin Daemon"; 44 uid = config.ids.uids.spamd; 45 group = "spamd"; 46 }; 47 48 users.extraGroups = singleton { 49 name = "spamd"; 50 gid = config.ids.gids.spamd; 51 }; 52 53 systemd.services.spamd = { 54 description = "Spam Assassin Server"; 55 56 wantedBy = [ "multi-user.target" ]; 57 after = [ "network.target" ]; 58 59 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"; 60 }; 61 }; 62}