10 cfg = config.services.prometheus.exporters.imap-mailstat;
13 if (builtins.typeOf value == "string") then
17 if (builtins.typeOf value == "int") then
21 if (builtins.typeOf value == "bool") then
22 (if value then "true" else "false")
24 "XXX ${toString value}"
38 # unfortunately on toTOML yet
39 # https://github.com/NixOS/nix/issues/3929
40 pkgs.writeText "imap-mailstat-exporter.conf" ''
45 "[[Accounts]]\nname = \"${name}\"\n${
46 concatStrings (attrValues (mapAttrs (k: v: "${k} = ${valueToString v}\n") config))
55 type = types.nullOr type;
57 description = description;
59 accountOptions.options = {
60 mailaddress = mkOpt types.str "Your email address (at the moment used as login name)";
61 username = mkOpt types.str "If empty string mailaddress value is used";
62 password = mkOpt types.str "";
63 serveraddress = mkOpt types.str "mailserver name or address";
64 serverport = mkOpt types.int "imap port number (at the moment only tls connection is supported)";
65 starttls = mkOpt types.bool "set to true for using STARTTLS to start a TLS connection";
71 oldestUnseenDate = mkOption {
75 Enable metric with timestamp of oldest unseen mail
79 type = types.attrsOf (types.submodule accountOptions);
85 configurationFile = mkOption {
87 example = "/path/to/config-file";
89 File containing the configuration
96 ${pkgs.prometheus-imap-mailstat-exporter}/bin/imap-mailstat-exporter \
97 -config ${createConfigFile cfg.accounts} \
98 ${optionalString cfg.oldestUnseenDate "-oldestunseendate"} \
99 ${concatStringsSep " \\\n " cfg.extraFlags}