···
28
-
datasourceFile = mkProvisionCfg "datasource" "datasources" cfg.provision.datasources;
29
-
dashboardFile = mkProvisionCfg "dashboard" "providers" cfg.provision.dashboards;
28
+
datasourceFileOrDir = mkProvisionCfg "datasource" "datasources" cfg.provision.datasources;
29
+
dashboardFileOrDir = mkProvisionCfg "dashboard" "providers" cfg.provision.dashboards;
notifierConfiguration = {
notifiers = cfg.provision.notifiers;
36
-
notifierFile = pkgs.writeText "notifier.yaml" (builtins.toJSON notifierConfiguration);
36
+
notifierFileOrDir = pkgs.writeText "notifier.yaml" (builtins.toJSON notifierConfiguration);
generateAlertingProvisioningYaml = x: if (cfg.provision.alerting."${x}".path == null)
then provisioningSettingsFormat.generate "${x}.yaml" cfg.provision.alerting."${x}".settings
else cfg.provision.alerting."${x}".path;
41
-
rulesFile = generateAlertingProvisioningYaml "rules";
42
-
contactPointsFile = generateAlertingProvisioningYaml "contactPoints";
43
-
policiesFile = generateAlertingProvisioningYaml "policies";
44
-
templatesFile = generateAlertingProvisioningYaml "templates";
45
-
muteTimingsFile = generateAlertingProvisioningYaml "muteTimings";
41
+
rulesFileOrDir = generateAlertingProvisioningYaml "rules";
42
+
contactPointsFileOrDir = generateAlertingProvisioningYaml "contactPoints";
43
+
policiesFileOrDir = generateAlertingProvisioningYaml "policies";
44
+
templatesFileOrDir = generateAlertingProvisioningYaml "templates";
45
+
muteTimingsFileOrDir = generateAlertingProvisioningYaml "muteTimings";
47
-
provisionConfDir = pkgs.runCommand "grafana-provisioning" { } ''
47
+
ln = { src, dir, filename }: ''
48
+
if [[ -d "${src}" ]]; then
49
+
pushd $out/${dir} &>/dev/null
53
+
ln -sf ${src} $out/${dir}/${filename}.yaml
56
+
provisionConfDir = pkgs.runCommand "grafana-provisioning" { nativeBuildInputs = [ pkgs.xorg.lndir ]; } ''
mkdir -p $out/{datasources,dashboards,notifiers,alerting}
49
-
ln -sf ${datasourceFile} $out/datasources/datasource.yaml
50
-
ln -sf ${dashboardFile} $out/dashboards/dashboard.yaml
51
-
ln -sf ${notifierFile} $out/notifiers/notifier.yaml
52
-
ln -sf ${rulesFile} $out/alerting/rules.yaml
53
-
ln -sf ${contactPointsFile} $out/alerting/contactPoints.yaml
54
-
ln -sf ${policiesFile} $out/alerting/policies.yaml
55
-
ln -sf ${templatesFile} $out/alerting/templates.yaml
56
-
ln -sf ${muteTimingsFile} $out/alerting/muteTimings.yaml
58
+
${ln { src = datasourceFileOrDir; dir = "datasources"; filename = "datasource"; }}
59
+
${ln { src = dashboardFileOrDir; dir = "dashboards"; filename = "dashbaord"; }}
60
+
${ln { src = notifierFileOrDir; dir = "notifiers"; filename = "notifier"; }}
61
+
${ln { src = rulesFileOrDir; dir = "alerting"; filename = "rules"; }}
62
+
${ln { src = contactPointsFileOrDir; dir = "alerting"; filename = "contactPoints"; }}
63
+
${ln { src = policiesFileOrDir; dir = "alerting"; filename = "policies"; }}
64
+
${ln { src = templatesFileOrDir; dir = "alerting"; filename = "templates"; }}
65
+
${ln { src = muteTimingsFileOrDir; dir = "alerting"; filename = "muteTimings"; }}
# Get a submodule without any embedded metadata:
_filter = x: filterAttrs (k: v: k != "_module") x;
# FIXME(@Ma27) remove before 23.05. This is just a helper-type
63
-
# because `mkRenamedOptionModule` doesn't work if `foo.bar` is renamed
72
+
# because `mkRenamedOptionMthere's there's odule` doesn't work if `foo.bar` is renamed
submodule' = module: types.coercedTo
···
Don't change the value of this option if you are planning to use `services.grafana.provision` options.
default = provisionConfDir;
345
-
defaultText = literalExpression ''
346
-
pkgs.runCommand "grafana-provisioning" { } \'\'
347
-
mkdir -p $out/{datasources,dashboards,notifiers,alerting}
348
-
ln -sf ''${datasourceFile} $out/datasources/datasource.yaml
349
-
ln -sf ''${dashboardFile} $out/dashboards/dashboard.yaml
350
-
ln -sf ''${notifierFile} $out/notifiers/notifier.yaml
351
-
ln -sf ''${rulesFile} $out/alerting/rules.yaml
352
-
ln -sf ''${contactPointsFile} $out/alerting/contactPoints.yaml
353
-
ln -sf ''${policiesFile} $out/alerting/policies.yaml
354
-
ln -sf ''${templatesFile} $out/alerting/templates.yaml
355
-
ln -sf ''${muteTimingsFile} $out/alerting/muteTimings.yaml
354
+
defaultText = "directory with all provisioning files linked together";
···
description = lib.mdDoc ''
Path to YAML datasource configuration. Can't be used with
[](#opt-services.grafana.provision.datasources.settings) simultaneously.
641
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Path to YAML dashboard configuration. Can't be used with
[](#opt-services.grafana.provision.dashboards.settings) simultaneously.
693
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Path to YAML rules configuration. Can't be used with
[](#opt-services.grafana.provision.alerting.rules.settings) simultaneously.
716
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Path to YAML contact points configuration. Can't be used with
[](#opt-services.grafana.provision.alerting.contactPoints.settings) simultaneously.
840
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Path to YAML notification policies configuration. Can't be used with
[](#opt-services.grafana.provision.alerting.policies.settings) simultaneously.
921
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Path to YAML templates configuration. Can't be used with
[](#opt-services.grafana.provision.alerting.templates.settings) simultaneously.
991
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;
···
description = lib.mdDoc ''
Path to YAML mute timings configuration. Can't be used with
[](#opt-services.grafana.provision.alerting.muteTimings.settings) simultaneously.
1073
+
Can be either a directory or a single YAML file. Will end up in the store.
type = types.nullOr types.path;