nixos/grafana: fix w/o datasources or dashboard provisioning

This commit is contained in:
Maximilian Bosch 2022-11-08 20:04:23 +01:00
parent 4ec456b725
commit 2f1dfb0db3
No known key found for this signature in database
GPG Key ID: 9A6EEA275CA5BE0A

View File

@ -13,9 +13,20 @@ let
settingsFormatIni = pkgs.formats.ini {};
configFile = settingsFormatIni.generate "config.ini" cfg.settings;
datasourceFile = if (cfg.provision.datasources.path == null) then provisioningSettingsFormat.generate "datasource.yaml" cfg.provision.datasources.settings else cfg.provision.datasources.path;
mkProvisionCfg = name: attr: provisionCfg:
if provisionCfg.path != null
then provisionCfg.path
else
provisioningSettingsFormat.generate "${name}.yaml"
(if provisionCfg.settings != null
then provisionCfg.settings
else {
apiVersion = 1;
${attr} = [];
});
dashboardFile = if (cfg.provision.dashboards.path == null) then provisioningSettingsFormat.generate "dashboard.yaml" cfg.provision.dashboards.settings else cfg.provision.dashboards.path;
datasourceFile = mkProvisionCfg "datasource" "datasources" cfg.provision.datasources;
dashboardFile = mkProvisionCfg "dashboard" "providers" cfg.provision.dashboards;
notifierConfiguration = {
apiVersion = 1;