diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2021-08-26 00:28:49 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2021-08-26 00:28:49 +0200 |
commit | 5773ae93f75cfd504d7971c1b26955fa50a00744 (patch) | |
tree | d5f19ba068e4efee4f711e1dad969cf3b3c61470 /lib/options.nix | |
parent | b6d3c9f821b704fbfb68d20a76520fa9e160df36 (diff) | |
download | nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.tar nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.tar.gz nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.tar.bz2 nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.tar.lz nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.tar.xz nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.tar.zst nixpkgs-5773ae93f75cfd504d7971c1b26955fa50a00744.zip |
lib/generators: move limit detection into `withRecursion`
As suggested in #131205. Now it's possible to pretty-print a value with `lib.generators` like this: with lib.generators; toPretty { } (withRecursion { depthLimit = 10; } /* arbitrarily complex value */) Also, this can be used for any other pretty-printer now if needed.
Diffstat (limited to 'lib/options.nix')
-rw-r--r-- | lib/options.nix | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/options.nix b/lib/options.nix index 4b39ce824ea..119a67fb7d8 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -247,7 +247,9 @@ rec { showDefs = defs: concatMapStrings (def: let # Pretty print the value for display, if successful - prettyEval = builtins.tryEval (lib.generators.toPretty { depthLimit = 10; } def.value); + prettyEval = builtins.tryEval + (lib.generators.toPretty { } + (lib.generators.withRecursion { depthLimit = 10; throwOnDepthLimit = false; } def.value)); # Split it into its lines lines = filter (v: ! isList v) (builtins.split "\n" prettyEval.value); # Only display the first 5 lines, and indent them for better visibility |