diff options
author | Maximilian Bosch <maximilian@mbosch.me> | 2021-07-23 10:49:51 +0200 |
---|---|---|
committer | Maximilian Bosch <maximilian@mbosch.me> | 2021-08-25 23:18:27 +0200 |
commit | fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a (patch) | |
tree | df06e9d4c57407c0acf9e4da258389175c49427f /lib/options.nix | |
parent | 55ea29fd8c7a4b130a114b0f06b3fadfaf028356 (diff) | |
download | nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.tar nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.tar.gz nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.tar.bz2 nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.tar.lz nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.tar.xz nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.tar.zst nixpkgs-fbc9084c39297f6a8ca618b0f6a3ccdd4489ab6a.zip |
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`.
Diffstat (limited to 'lib/options.nix')
-rw-r--r-- | lib/options.nix | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/options.nix b/lib/options.nix index 204c86df9f5..4b39ce824ea 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 |