1 { config, lib, pkgs, ... }:
4 cfg = config.services.rspamd-trainer;
5 format = pkgs.formats.toml { };
8 options.services.rspamd-trainer = {
10 enable = lib.mkEnableOption "Spam/ham trainer for rspamd";
12 settings = lib.mkOption {
15 IMAP authentication configuration for rspamd-trainer. For supplying
16 the IMAP password, use the `secrets` option.
18 type = lib.types.submodule {
19 freeformType = format.type;
21 example = lib.literalExpression ''
24 USERNAME = "spam@example.com";
25 INBOXPREFIX = "INBOX/";
30 secrets = lib.mkOption {
31 type = with lib.types; listOf path;
33 A list of files containing the various secrets. Should be in the
34 format expected by systemd's `EnvironmentFile` directory. For the
35 IMAP account password use `PASSWORD = mypassword`.
42 config = lib.mkIf cfg.enable {
45 services.rspamd-trainer = {
46 description = "Spam/ham trainer for rspamd";
48 ExecStart = "${pkgs.rspamd-trainer}/bin/rspamd-trainer";
49 WorkingDirectory = "/var/lib/rspamd-trainer";
50 StateDirectory = [ "rspamd-trainer/log" ];
54 ( format.generate "rspamd-trainer-env" cfg.settings )
59 timers."rspamd-trainer" = {
60 wantedBy = [ "timers.target" ];
63 OnUnitActiveSec = "10m";
64 Unit = "rspamd-trainer.service";
71 meta.maintainers = with lib.maintainers; [ onny ];