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:
+1
-1
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user