2023-10-18 09:47:00 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.services.rspamd-trainer;
|
|
|
|
format = pkgs.formats.toml { };
|
|
|
|
|
|
|
|
in {
|
|
|
|
options.services.rspamd-trainer = {
|
|
|
|
|
2024-08-28 19:18:57 +00:00
|
|
|
enable = lib.mkEnableOption "Spam/ham trainer for rspamd";
|
2023-10-18 09:47:00 +00:00
|
|
|
|
2024-08-28 19:18:57 +00:00
|
|
|
settings = lib.mkOption {
|
2023-10-18 09:47:00 +00:00
|
|
|
default = { };
|
|
|
|
description = ''
|
|
|
|
IMAP authentication configuration for rspamd-trainer. For supplying
|
|
|
|
the IMAP password, use the `secrets` option.
|
|
|
|
'';
|
2024-08-28 19:18:57 +00:00
|
|
|
type = lib.types.submodule {
|
2023-10-18 09:47:00 +00:00
|
|
|
freeformType = format.type;
|
|
|
|
};
|
2024-08-28 19:18:57 +00:00
|
|
|
example = lib.literalExpression ''
|
2023-10-18 09:47:00 +00:00
|
|
|
{
|
|
|
|
HOST = "localhost";
|
|
|
|
USERNAME = "spam@example.com";
|
|
|
|
INBOXPREFIX = "INBOX/";
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
secrets = lib.mkOption {
|
2024-08-28 19:18:57 +00:00
|
|
|
type = with lib.types; listOf path;
|
2023-10-18 09:47:00 +00:00
|
|
|
description = ''
|
|
|
|
A list of files containing the various secrets. Should be in the
|
|
|
|
format expected by systemd's `EnvironmentFile` directory. For the
|
|
|
|
IMAP account password use `PASSWORD = mypassword`.
|
|
|
|
'';
|
|
|
|
default = [ ];
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2024-08-28 19:18:57 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2023-10-18 09:47:00 +00:00
|
|
|
|
|
|
|
systemd = {
|
|
|
|
services.rspamd-trainer = {
|
|
|
|
description = "Spam/ham trainer for rspamd";
|
|
|
|
serviceConfig = {
|
|
|
|
ExecStart = "${pkgs.rspamd-trainer}/bin/rspamd-trainer";
|
|
|
|
WorkingDirectory = "/var/lib/rspamd-trainer";
|
|
|
|
StateDirectory = [ "rspamd-trainer/log" ];
|
|
|
|
Type = "oneshot";
|
|
|
|
DynamicUser = true;
|
|
|
|
EnvironmentFile = [
|
|
|
|
( format.generate "rspamd-trainer-env" cfg.settings )
|
|
|
|
cfg.secrets
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
timers."rspamd-trainer" = {
|
|
|
|
wantedBy = [ "timers.target" ];
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = "10m";
|
|
|
|
OnUnitActiveSec = "10m";
|
|
|
|
Unit = "rspamd-trainer.service";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
meta.maintainers = with lib.maintainers; [ onny ];
|
|
|
|
|
|
|
|
}
|