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.