summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2021-01-31 21:20:17 +0100
committerGitHub <noreply@github.com>2021-01-31 21:20:17 +0100
commit59b45d66b23a500fd1969639c512284f3cbcb0b9 (patch)
treed0a34cc047a87097ec474173f70dabfb69b3ef51
parent919b1f5466ddeb8a3e450e6e785bba7b4f8ab723 (diff)
parentd9a7d03da8c58aa863911506ae3153729f8931da (diff)
Merge pull request #111469 from sternenseemann/topretty-fix-currying
lib/generators: fix toPretty throwing on (partially applied) builtins
-rw-r--r--lib/generators.nix13
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/generators.nix b/lib/generators.nix
index 501a23599f45..9546f5b5b0ab 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -236,12 +236,17 @@ rec {
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
+ outroSpace + "]"
else if isFunction v then
- let fna = lib.functionArgs v;
+ # functionArgs throws in case of (partially applied) builtins
+ # on nix before commit b2748c6e99239ff6803ba0da76c362790c8be192
+ # which includes current nix stable
+ # TODO remove tryEval workaround when the issue is resolved on nix stable
+ let fna = builtins.tryEval (lib.functionArgs v);
showFnas = concatStringsSep ", " (libAttr.mapAttrsToList
(name: hasDefVal: if hasDefVal then name + "?" else name)
- fna);
- in if fna == {} then "<function>"
- else "<function, args: {${showFnas}}>"
+ fna.value);
+ in if !fna.success || fna.value == {}
+ then "<function>"
+ else "<function, args: {${showFnas}}>"
else if isAttrs v then
# apply pretty values if allowed
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues