at master 1.8 kB view raw
1{ 2 config, 3 lib, 4 pkgs, 5 ... 6}: 7 8let 9 cfg = config.services.prometheus.exporters.mailman3; 10in 11{ 12 port = 9934; 13 extraOpts = { 14 logLevel = lib.mkOption { 15 type = lib.types.enum [ 16 "debug" 17 "info" 18 "warning" 19 "error" 20 "critical" 21 ]; 22 default = "info"; 23 description = '' 24 Detail level to log. 25 ''; 26 }; 27 28 mailman = { 29 addr = lib.mkOption { 30 type = lib.types.str; 31 default = "http://127.0.0.1:8001"; 32 description = '' 33 Mailman3 Core REST API address. 34 ''; 35 }; 36 37 user = lib.mkOption { 38 type = lib.types.str; 39 default = "restadmin"; 40 description = '' 41 Mailman3 Core REST API username. 42 ''; 43 }; 44 45 passFile = lib.mkOption { 46 type = lib.types.str; 47 default = config.services.mailman.restApiPassFile; 48 defaultText = lib.literalExpression "config.services.mailman.restApiPassFile"; 49 description = '' 50 Mailman3 Core REST API password. 51 ''; 52 }; 53 }; 54 }; 55 serviceOpts = { 56 serviceConfig = { 57 LoadCredential = [ 58 "password:${cfg.mailman.passFile}" 59 ]; 60 ExecStart = 61 let 62 addr = "${ 63 if (lib.hasInfix ":" cfg.listenAddress) then "[${cfg.listenAddress}]" else cfg.listenAddress 64 }:${toString cfg.port}"; 65 in 66 '' 67 ${lib.getExe pkgs.prometheus-mailman3-exporter} \ 68 --log-level ${cfg.logLevel} \ 69 --web.listen ${addr} \ 70 --mailman.address ${cfg.mailman.addr} \ 71 --mailman.user ${cfg.mailman.user} \ 72 --mailman.password-file %d/password \ 73 ${lib.concatStringsSep " \\\n " cfg.extraFlags} 74 ''; 75 }; 76 }; 77}