at 25.11-pre 1.9 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7let 8 9 cfg = config.services.rspamd-trainer; 10 format = pkgs.formats.toml { }; 11 12in 13{ 14 options.services.rspamd-trainer = { 15 16 enable = lib.mkEnableOption "Spam/ham trainer for rspamd"; 17 18 settings = lib.mkOption { 19 default = { }; 20 description = '' 21 IMAP authentication configuration for rspamd-trainer. For supplying 22 the IMAP password, use the `secrets` option. 23 ''; 24 type = lib.types.submodule { 25 freeformType = format.type; 26 }; 27 example = lib.literalExpression '' 28 { 29 HOST = "localhost"; 30 USERNAME = "spam@example.com"; 31 INBOXPREFIX = "INBOX/"; 32 } 33 ''; 34 }; 35 36 secrets = lib.mkOption { 37 type = with lib.types; listOf path; 38 description = '' 39 A list of files containing the various secrets. Should be in the 40 format expected by systemd's `EnvironmentFile` directory. For the 41 IMAP account password use `PASSWORD = mypassword`. 42 ''; 43 default = [ ]; 44 }; 45 46 }; 47 48 config = lib.mkIf cfg.enable { 49 50 systemd = { 51 services.rspamd-trainer = { 52 description = "Spam/ham trainer for rspamd"; 53 serviceConfig = { 54 ExecStart = "${pkgs.rspamd-trainer}/bin/rspamd-trainer"; 55 WorkingDirectory = "/var/lib/rspamd-trainer"; 56 StateDirectory = [ "rspamd-trainer/log" ]; 57 Type = "oneshot"; 58 DynamicUser = true; 59 EnvironmentFile = [ 60 (format.generate "rspamd-trainer-env" cfg.settings) 61 cfg.secrets 62 ]; 63 }; 64 }; 65 timers."rspamd-trainer" = { 66 wantedBy = [ "timers.target" ]; 67 timerConfig = { 68 OnBootSec = "10m"; 69 OnUnitActiveSec = "10m"; 70 Unit = "rspamd-trainer.service"; 71 }; 72 }; 73 }; 74 75 }; 76 77 meta.maintainers = with lib.maintainers; [ onny ]; 78 79}