From 94b7b469aa6ae3f3b7adb08d325eaa6eb434735e Mon Sep 17 00:00:00 2001 From: nicoo Date: Sat, 25 May 2024 19:05:56 +0000 Subject: [PATCH] nixos/promtail: Replace custom `jq`-based `runCommand` with `pkgs.formats` --- nixos/modules/services/logging/promtail.nix | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/nixos/modules/services/logging/promtail.nix b/nixos/modules/services/logging/promtail.nix index d6038055c05c..7dabe13de41d 100644 --- a/nixos/modules/services/logging/promtail.nix +++ b/nixos/modules/services/logging/promtail.nix @@ -2,9 +2,11 @@ let cfg = config.services.promtail; - prettyJSON = conf: pkgs.runCommandLocal "promtail-config.json" {} '' - echo '${builtins.toJSON conf}' | ${pkgs.buildPackages.jq}/bin/jq 'del(._module)' > $out - ''; + format = pkgs.formats.json {}; + prettyJSON = conf: with lib; pipe conf [ + (flip removeAttrs [ "_module" ]) + (format.generate "promtail-config.json") + ]; allowSystemdJournal = cfg.configuration ? scrape_configs && lib.any (v: v ? journal) cfg.configuration.scrape_configs; @@ -20,7 +22,7 @@ in { enable = mkEnableOption "the Promtail ingresser"; configuration = mkOption { - type = (pkgs.formats.json {}).type; + type = format.type; description = '' Specify the configuration for Promtail in Nix. This option will be ignored if `services.promtail.configFile` is defined.