nixos/prometheus-mail-exporter: fix assertion

The assertion was printed when user explicitly defined only the
configFile option.
This commit is contained in:
Martin Milata 2020-03-06 01:41:40 +01:00
parent 2a080ac434
commit 3b5cf35e8b
2 changed files with 6 additions and 4 deletions

View File

@ -205,7 +205,9 @@ in
or `services.prometheus.exporters.snmp.configurationPath' set!
'';
} {
assertion = (cfg.mail.configFile == null) != (cfg.mail.configuration == {});
assertion = cfg.mail.enable -> (
(cfg.mail.configFile == null) != (cfg.mail.configuration == null)
);
message = ''
Please specify either 'services.prometheus.exporters.mail.configuration'
or 'services.prometheus.exporters.mail.configFile'.

View File

@ -127,8 +127,8 @@ in
'';
};
configuration = mkOption {
type = types.submodule exporterOptions;
default = {};
type = types.nullOr (types.submodule exporterOptions);
default = null;
description = ''
Specify the mailexporter configuration file to use.
'';
@ -148,7 +148,7 @@ in
${pkgs.prometheus-mail-exporter}/bin/mailexporter \
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} \
--config.file ${
if cfg.configuration != {} then configurationFile else (escapeShellArg cfg.configFile)
if cfg.configuration != null then configurationFile else (escapeShellArg cfg.configFile)
} \
${concatStringsSep " \\\n " cfg.extraFlags}
'';