]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - systems/eldiron/mail/rspamd.nix
Squash changes containing private information
[perso/Immae/Config/Nix.git] / systems / eldiron / mail / rspamd.nix
CommitLineData
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 {
8415083e
IB
14 services.cron.systemCronJobs = let
15 cron_script = pkgs.runCommand "cron_script" {
16 buildInputs = [ pkgs.makeWrapper ];
17 } ''
18 mkdir -p $out
19 cp ${./scan_reported_mails} $out/scan_reported_mails
20 patchShebangs $out
21 for i in $out/*; do
22 wrapProgram "$i" --prefix PATH : ${lib.makeBinPath [ pkgs.coreutils pkgs.rspamd pkgs.flock ]}
23 done
a929614f 24 '';
8415083e
IB
25 in
26 [ "*/20 * * * * vhost ${cron_script}/scan_reported_mails" ];
27
850adcf4 28 systemd.services.rspamd.serviceConfig.Slice = "mail.slice";
1a64deeb 29 systemd.services.rspamd.serviceConfig.SupplementaryGroups = [ "vhost" ];
8415083e
IB
30 services.rspamd = {
31 enable = true;
34a16461 32 debug = false;
8415083e
IB
33 overrides = {
34 "actions.conf".text = ''
35 reject = null;
36 add_header = 6;
37 greylist = null;
38 '';
39 "milter_headers.conf".text = ''
40 extended_spam_headers = true;
a929614f 41 '';
8415083e
IB
42 };
43 locals = {
44 "redis.conf".text = ''
ab8f306d
IB
45 servers = "${config.myEnv.mail.rspamd.redis.socket}";
46 db = "${config.myEnv.mail.rspamd.redis.db}";
8415083e
IB
47 '';
48 "classifier-bayes.conf".text = ''
49 users_enabled = true;
a929614f 50 backend = "redis";
ab8f306d
IB
51 servers = "${config.myEnv.mail.rspamd.redis.socket}";
52 database = "${config.myEnv.mail.rspamd.redis.db}";
8415083e
IB
53 autolearn = true;
54 cache {
55 backend = "redis";
a929614f 56 }
8415083e
IB
57 new_schema = true;
58 statfile {
59 BAYES_HAM {
60 spam = false;
61 }
62 BAYES_SPAM {
63 spam = true;
64 }
a929614f 65 }
8415083e
IB
66 '';
67 };
68 workers = {
69 controller = {
70 extraConfig = ''
ab8f306d
IB
71 enable_password = "${config.myEnv.mail.rspamd.write_password_hashed}";
72 password = "${config.myEnv.mail.rspamd.read_password_hashed}";
8415083e
IB
73 '';
74 bindSockets = [ {
75 socket = config.myServices.mail.rspamd.sockets.worker-controller;
76 mode = "0660";
77 owner = config.services.rspamd.user;
78 group = "vhost";
79 } ];
80 };
81 };
82 postfix = {
83 enable = true;
84 config = {};
a929614f 85 };
a929614f
IB
86 };
87 };
88}