nixos/prometheus-snmp-exporter: fix assertion

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

Changed files
+5 -3
nixos
modules
services
monitoring
prometheus
+3 -1
nixos/modules/services/monitoring/prometheus/exporters.nix
···
config = mkMerge ([{
assertions = [ {
-
assertion = (cfg.snmp.configurationPath == null) != (cfg.snmp.configuration == null);
+
assertion = cfg.snmp.enable -> (
+
(cfg.snmp.configurationPath == null) != (cfg.snmp.configuration == null)
+
);
message = ''
Please ensure you have either `services.prometheus.exporters.snmp.configuration'
or `services.prometheus.exporters.snmp.configurationPath' set!
+2 -2
nixos/modules/services/monitoring/prometheus/exporters/snmp.nix
···
configuration = mkOption {
type = types.nullOr types.attrs;
-
default = {};
+
default = null;
description = ''
Snmp exporter configuration as nix attribute set. Mutually exclusive with 'configurationPath' option.
'';
···
serviceOpts = let
configFile = if cfg.configurationPath != null
then cfg.configurationPath
-
else "${pkgs.writeText "snmp-eporter-conf.yml" (builtins.toJSON cfg.configuration)}";
+
else "${pkgs.writeText "snmp-exporter-conf.yml" (builtins.toJSON cfg.configuration)}";
in {
serviceConfig = {
ExecStart = ''