Skip to content

Commit

Permalink
feat(grafana): add providers configuration
Browse files Browse the repository at this point in the history
Addresses #210.
  • Loading branch information
Alex Pearwin committed Jun 6, 2024
1 parent 8d64812 commit 46e91e7
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion nix/grafana.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ in

datasources = lib.mkOption {
type = types.listOf yamlFormat.type;
description = "List of data sources to configure.";
description = ''
List of data sources to configure.
See https://grafana.com/docs/grafana/latest/administration/provisioning/#data-sources for the schema.
'';
default = [ ];
example = ''
[
Expand All @@ -75,6 +79,28 @@ in
'';
};

providers = lib.mkOption {
type = types.listOf yamlFormat.type;
description = ''
List of dashboard providers to configure.
See https://grafana.com/docs/grafana/latest/administration/provisioning/#dashboards for the schema.
'';
default = [ ];
example = ''
[
{
name = "Databases";
type = "file";
options = {
path = ./dashboards;
foldersFromFilesStructure = true;
};
}
]
'';
};

outputs.settings = lib.mkOption {
type = types.deferredModule;
internal = true;
Expand All @@ -97,10 +123,15 @@ in
deleteDatasources = config.deleteDatasources;
datasources = config.datasources;
};
providersYaml = yamlFormat.generate "providers.yaml" {
apiVersion = 1;
providers = config.providers;
};
buildCommand = ''
mkdir -p $out
mkdir -p $out/alerting
mkdir -p $out/dashboards
ln -s "$providersYaml" "$out/dashboards/providers.yaml"
mkdir -p $out/datasources
ln -s "$datasourcesYaml" "$out/datasources/datasources.yaml"
mkdir -p $out/notifiers
Expand Down

0 comments on commit 46e91e7

Please sign in to comment.