mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-04-17 05:28:40 +00:00
lib/options: use depthLimit
for toPretty
when showing a definition
When having a bogus declaration such as { lib, ... }: { foo.bar = mkOption { type = types.str; }; } the evaluation will terminate with a not-so helpful error: stack overflow (possible infinite recursion) To make sure a useful error is still provided, I added a `depthLimit` of `10` which should be perfectly sufficient to `toPretty` when it's used in an error-case for `showDefs`.
This commit is contained in:
parent
55ea29fd8c
commit
fbc9084c39
@ -247,7 +247,7 @@ rec {
|
||||
showDefs = defs: concatMapStrings (def:
|
||||
let
|
||||
# Pretty print the value for display, if successful
|
||||
prettyEval = builtins.tryEval (lib.generators.toPretty {} def.value);
|
||||
prettyEval = builtins.tryEval (lib.generators.toPretty { depthLimit = 10; } 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
|
||||
|
Loading…
Reference in New Issue
Block a user