aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorSilvan Mosberger <contact@infinisil.com>2020-09-17 18:18:50 +0200
committerSilvan Mosberger <contact@infinisil.com>2020-09-17 18:20:43 +0200
commit15c5ba9d28dbdcebd3320864b62fdc7f2b37defd (patch)
treee4a9b7c8d03fe62ef51cdd7ab45267c716afb6a0 /lib
parent05e4d371ef5c3819b969d34eb76ed7e4b3c99027 (diff)
lib/generators.toPretty: functors should print as functions
Not attribute sets. So move the function case forward
Diffstat (limited to 'lib')
-rw-r--r--lib/generators.nix14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/generators.nix b/lib/generators.nix
index 716ae77973f4..501a23599f45 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -235,6 +235,13 @@ rec {
else "[" + introSpace
+ libStr.concatMapStringsSep introSpace (go (indent + " ")) v
+ outroSpace + "]"
+ else if isFunction v then
+ let fna = 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}}>"
else if isAttrs v then
# apply pretty values if allowed
if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
@@ -247,13 +254,6 @@ rec {
(name: value:
"${libStr.escapeNixIdentifier name} = ${go (indent + " ") value};") v)
+ outroSpace + "}"
- else if isFunction v then
- let fna = 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}}>"
else abort "generators.toPretty: should never happen (v = ${v})";
in go "";