nixos/prometheus-nginx-exporter: only create service if nginx exporter is enabled

On a system with nginx enabled but the prometheus exporter not enabled,
the prometheus-nginx-exporter service should not be created.
This commit is contained in:
Logan Glasson 2021-02-08 12:03:11 +13:00
parent 98dd794037
commit c6ec272c78
2 changed files with 5 additions and 5 deletions

View File

@ -238,9 +238,6 @@ in
services.prometheus.exporters.minio.minioAccessSecret = mkDefault config.services.minio.secretKey;
})] ++ [(mkIf config.services.prometheus.exporters.rtl_433.enable {
hardware.rtl-sdr.enable = mkDefault true;
})] ++ [(mkIf config.services.nginx.enable {
systemd.services.prometheus-nginx-exporter.after = [ "nginx.service" ];
systemd.services.prometheus-nginx-exporter.requires = [ "nginx.service" ];
})] ++ [(mkIf config.services.postfix.enable {
services.prometheus.exporters.postfix.group = mkDefault config.services.postfix.setgidGroup;
})] ++ (mapAttrsToList (name: conf:

View File

@ -42,7 +42,7 @@ in
'';
};
};
serviceOpts = {
serviceOpts = mkMerge ([{
serviceConfig = {
ExecStart = ''
${pkgs.prometheus-nginx-exporter}/bin/nginx-prometheus-exporter \
@ -54,7 +54,10 @@ in
${concatStringsSep " \\\n " cfg.extraFlags}
'';
};
};
}] ++ [(mkIf config.services.nginx.enable {
after = [ "nginx.service" ];
requires = [ "nginx.service" ];
})]);
imports = [
(mkRenamedOptionModule [ "telemetryEndpoint" ] [ "telemetryPath" ])
(mkRemovedOptionModule [ "insecure" ] ''