mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos: Replace custom cfg format handling with pkgs.formats
(#314933)
This commit is contained in:
commit
dca7e827b3
6 changed files with 33 additions and 88 deletions
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue