nixos/prometheus-mail-exporter: fix assertion

The assertion was printed when user explicitly defined only the
configFile option.

Changed files
+6 -4
nixos
modules
services
monitoring
prometheus
+3 -1
nixos/modules/services/monitoring/prometheus/exporters.nix
···
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'.
+3 -3
nixos/modules/services/monitoring/prometheus/exporters/mail.nix
···
'';
};
configuration = mkOption {
-
type = types.submodule exporterOptions;
-
default = {};
+
type = types.nullOr (types.submodule exporterOptions);
+
default = null;
description = ''
Specify the mailexporter configuration file to use.
'';
···
${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}
'';