From 8d7f3c9dbde7d235f3e256f2dc13ec07e68f60f6 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Wed, 15 May 2024 18:03:48 +0100 Subject: nixos/loki: Implement configuration verification Fixes: #293088 --- nixos/modules/services/monitoring/loki.nix | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nixos') diff --git a/nixos/modules/services/monitoring/loki.nix b/nixos/modules/services/monitoring/loki.nix index ba63f95e7f1a8..a53830fd64c80 100644 --- a/nixos/modules/services/monitoring/loki.nix +++ b/nixos/modules/services/monitoring/loki.nix @@ -99,9 +99,16 @@ in { conf = if cfg.configFile == null then prettyJSON cfg.configuration else cfg.configFile; + validateConfig = file: + pkgs.runCommand "validate-loki-conf" { + nativeBuildInputs = [ pkgs.grafana-loki ]; + } '' + loki -verify-config -config.file "${file}" + ln -s "${file}" "$out" + ''; in { - ExecStart = "${cfg.package}/bin/loki --config.file=${conf} ${escapeShellArgs cfg.extraFlags}"; + ExecStart = "${cfg.package}/bin/loki --config.file=${validateConfig conf} ${escapeShellArgs cfg.extraFlags}"; User = cfg.user; Restart = "always"; PrivateTmp = true; -- cgit 1.4.1