From fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 23 Jul 2021 10:49:51 +0200 Subject: 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`. --- lib/options.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/options.nix b/lib/options.nix index 204c86df9f510..4b39ce824ea07 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -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 -- cgit 1.4.1