]>
Commit | Line | Data |
---|---|---|
ab8f306d | 1 | { lib, pkgs, config, ... }: |
a929614f IB |
2 | { |
3 | options.myServices.mail.rspamd.sockets = lib.mkOption { | |
4 | type = lib.types.attrsOf lib.types.path; | |
5 | default = { | |
6 | worker-controller = "/run/rspamd/worker-controller.sock"; | |
7 | }; | |
8 | readOnly = true; | |
9 | description = '' | |
10 | rspamd sockets | |
11 | ''; | |
12 | }; | |
8415083e | 13 | config = lib.mkIf config.myServices.mail.enable { |
d2e703c5 | 14 | services.duplyBackup.profiles.mail.excludeFile = '' |
8415083e | 15 | + /var/lib/rspamd |
a929614f | 16 | ''; |
8415083e IB |
17 | services.cron.systemCronJobs = let |
18 | cron_script = pkgs.runCommand "cron_script" { | |
19 | buildInputs = [ pkgs.makeWrapper ]; | |
20 | } '' | |
21 | mkdir -p $out | |
22 | cp ${./scan_reported_mails} $out/scan_reported_mails | |
23 | patchShebangs $out | |
24 | for i in $out/*; do | |
25 | wrapProgram "$i" --prefix PATH : ${lib.makeBinPath [ pkgs.coreutils pkgs.rspamd pkgs.flock ]} | |
26 | done | |
a929614f | 27 | ''; |
8415083e IB |
28 | in |
29 | [ "*/20 * * * * vhost ${cron_script}/scan_reported_mails" ]; | |
30 | ||
31 | services.rspamd = { | |
32 | enable = true; | |
34a16461 | 33 | debug = false; |
8415083e IB |
34 | overrides = { |
35 | "actions.conf".text = '' | |
36 | reject = null; | |
37 | add_header = 6; | |
38 | greylist = null; | |
39 | ''; | |
40 | "milter_headers.conf".text = '' | |
41 | extended_spam_headers = true; | |
a929614f | 42 | ''; |
8415083e IB |
43 | }; |
44 | locals = { | |
45 | "redis.conf".text = '' | |
ab8f306d IB |
46 | servers = "${config.myEnv.mail.rspamd.redis.socket}"; |
47 | db = "${config.myEnv.mail.rspamd.redis.db}"; | |
8415083e IB |
48 | ''; |
49 | "classifier-bayes.conf".text = '' | |
50 | users_enabled = true; | |
a929614f | 51 | backend = "redis"; |
ab8f306d IB |
52 | servers = "${config.myEnv.mail.rspamd.redis.socket}"; |
53 | database = "${config.myEnv.mail.rspamd.redis.db}"; | |
8415083e IB |
54 | autolearn = true; |
55 | cache { | |
56 | backend = "redis"; | |
a929614f | 57 | } |
8415083e IB |
58 | new_schema = true; |
59 | statfile { | |
60 | BAYES_HAM { | |
61 | spam = false; | |
62 | } | |
63 | BAYES_SPAM { | |
64 | spam = true; | |
65 | } | |
a929614f | 66 | } |
8415083e IB |
67 | ''; |
68 | }; | |
69 | workers = { | |
70 | controller = { | |
71 | extraConfig = '' | |
ab8f306d IB |
72 | enable_password = "${config.myEnv.mail.rspamd.write_password_hashed}"; |
73 | password = "${config.myEnv.mail.rspamd.read_password_hashed}"; | |
8415083e IB |
74 | ''; |
75 | bindSockets = [ { | |
76 | socket = config.myServices.mail.rspamd.sockets.worker-controller; | |
77 | mode = "0660"; | |
78 | owner = config.services.rspamd.user; | |
79 | group = "vhost"; | |
80 | } ]; | |
81 | }; | |
82 | }; | |
83 | postfix = { | |
84 | enable = true; | |
85 | config = {}; | |
a929614f | 86 | }; |
a929614f IB |
87 | }; |
88 | }; | |
89 | } |