1 { pkgs, lib, config, ... }:
2 let inherit (builtins) attrNames listToAttrs readFile;
3 inherit (builtins.extraBuiltins) pass pass-chomp;
5 inherit (pkgs.lib) unlinesAttrs;
6 inherit (config) networking;
7 inherit (config.services) postfix rspamd dovecot2;
10 systemd.services.rspamd.after =
12 (domain: dom: "dkim.${domain}.${dom.selector}.key-key.service")
14 deployment.keys = lib.mapAttrs'
16 lib.nameValuePair "dkim.${domain}.${dom.selector}.key" {
17 text = pass dom.selectors."${dom.selector}".key;
20 destDir = "/run/keys/";
21 permissions = "0400"; # WARNING: not enforced when deployment.storeKeysOnMachine = true
24 users.users."${rspamd.user}".extraGroups = [ "keys" ];
29 enable = postfix.enable;
34 "${networking.hostName}" = {
35 selector = "20200101";
38 key = "dkim/${networking.domain}/20200101.key";
39 dns = readFile (rspamd/dkim + "/${networking.domain}/20200101.dns");
43 "${networking.domain}" = {
44 selector = "20200101";
47 key = "dkim/${networking.domain}/20200101.key";
48 dns = readFile (rspamd/dkim + "/${networking.domain}/20200101.dns");
55 let selector_map_file =
56 pkgs.writeText "dkim_selectors.map"
58 (domain: dom: "${domain} ${dom.selector}")
61 "dkim_signing.conf".text = ''
62 selector_map = ${selector_map_file};
63 path = "/run/keys/dkim.$domain.$selector.key";
64 allow_username_mismatch = true;
67 selector_map = ${selector_map_file};
68 path = "/run/keys/dkim.$domain.$selector.key";
69 allow_username_mismatch = true;
73 debug_modules = [“dkim_signing”]
78 "milter_headers.conf".text = ''
79 extended_spam_headers = true;
81 "actions.conf".text = ''
82 reject = 15; # Reject when reaching this score
83 add_header = 6; # Add header when reaching this score
84 greylist = 4; # Apply greylisting when reaching this score (will emit `soft reject action`)
89 # Like controller but without a password, only the bindSockets' permissions
91 includes = [ "$CONFDIR/worker-controller.inc" ];
93 { socket = "/run/rspamd/learner.sock";
95 owner = "${rspamd.user}";
96 group = "${dovecot2.group}";
103 includes = [ "$CONFDIR/worker-controller.inc" ];
109 #static_dir = "''${WWWDIR}";
111 password = "${pass-chomp "servers/mermet/rspamd/controller/hashedPassword"}";
117 services.postfix.extraConfig = ''
118 smtpd_milters = unix:/run/rspamd.sock
119 milter_default_action = accept
121 # Allow users to run 'rspamc' and 'rspamadm'.
122 environment.systemPackages = [ pkgs.rspamd ];