Merge pull request #169216 from Shawn8901/fix_prometheus_config_generation

nixos/prometheus: use pkgs.formats.json.generate to write config file
main
Sandro 2 years ago committed by GitHub
commit befb337461
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 9
      nixos/modules/services/monitoring/prometheus/default.nix

@ -3,6 +3,7 @@
with lib;
let
json = pkgs.formats.json { };
cfg = config.services.prometheus;
workingDir = "/var/lib/" + cfg.stateDir;
@ -34,13 +35,7 @@ let
promtool ${what} $out
'' else file;
# Pretty-print JSON to a file
writePrettyJSON = name: x:
pkgs.runCommandLocal name { } ''
echo '${builtins.toJSON x}' | ${pkgs.jq}/bin/jq . > $out
'';
generatedPrometheusYml = writePrettyJSON "prometheus.yml" promConfig;
generatedPrometheusYml = json.generate "prometheus.yml" promConfig;
# This becomes the main config file for Prometheus
promConfig = {

Loading…
Cancel
Save