From 05e4d371ef5c3819b969d34eb76ed7e4b3c99027 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Thu, 17 Sep 2020 18:14:18 +0200 Subject: lib/generators.toPretty: Print [] and {} compactly --- lib/generators.nix | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib/generators.nix') diff --git a/lib/generators.nix b/lib/generators.nix index 205092a2681..716ae77973f 100644 --- a/lib/generators.nix +++ b/lib/generators.nix @@ -230,13 +230,16 @@ rec { else if false == v then "false" else if null == v then "null" else if isPath v then toString v - else if isList v then "[" + introSpace + else if isList v then + if v == [] then "[ ]" + else "[" + introSpace + libStr.concatMapStringsSep introSpace (go (indent + " ")) v - + outroSpace + "]" + + outroSpace + "]" else if isAttrs v then # apply pretty values if allowed if attrNames v == [ "__pretty" "val" ] && allowPrettyValues then v.__pretty v.val + else if v == {} then "{ }" else if v ? type && v.type == "derivation" then "" else "{" + introSpace -- cgit 1.4.1