grafana: Use lib.mkIf instead of lib.optional

This commit is contained in:
SebastianStork 2025-11-22 18:25:49 +01:00
parent 68031a4cc4
commit 3081f16b64
Signed by: SebastianStork
SSH key fingerprint: SHA256:tRrGdjYOwgHxpSc/wTOZQZEjxcb15P0tyXRsbAfd+2Q

View file

@ -87,8 +87,8 @@ in
datasources.settings = { datasources.settings = {
prune = true; prune = true;
datasources = lib.concatLists [ datasources = [
(lib.optional cfg.datasources.prometheus.enable { (lib.mkIf cfg.datasources.prometheus.enable {
name = "Prometheus"; name = "Prometheus";
type = "prometheus"; type = "prometheus";
inherit (cfg.datasources.prometheus) url; inherit (cfg.datasources.prometheus) url;
@ -98,13 +98,13 @@ in
prometheusVersion = "2.50.0"; prometheusVersion = "2.50.0";
}; };
}) })
(lib.optional cfg.datasources.victoriametrics.enable { (lib.mkIf cfg.datasources.victoriametrics.enable {
name = "VictoriaMetrics"; name = "VictoriaMetrics";
type = "victoriametrics-metrics-datasource"; type = "victoriametrics-metrics-datasource";
inherit (cfg.datasources.victoriametrics) url; inherit (cfg.datasources.victoriametrics) url;
isDefault = false; isDefault = false;
}) })
(lib.optional cfg.datasources.victorialogs.enable { (lib.mkIf cfg.datasources.victorialogs.enable {
name = "VictoriaLogs"; name = "VictoriaLogs";
type = "victoriametrics-logs-datasource"; type = "victoriametrics-logs-datasource";
inherit (cfg.datasources.victorialogs) url; inherit (cfg.datasources.victorialogs) url;