about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--lib/generators.nix7
-rw-r--r--lib/tests/misc.nix4
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/generators.nix b/lib/generators.nix
index 205092a2681b5..716ae77973f41 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
         "<derivation ${v.drvPath}>"
       else "{" + introSpace
diff --git a/lib/tests/misc.nix b/lib/tests/misc.nix
index 2456b52c099c0..f60e6ad17870a 100644
--- a/lib/tests/misc.nix
+++ b/lib/tests/misc.nix
@@ -461,7 +461,9 @@ runTests {
       function = x: x;
       functionArgs = { arg ? 4, foo }: arg;
       list = [ 3 4 function [ false ] ];
+      emptylist = [];
       attrs = { foo = null; "foo bar" = "baz"; };
+      emptyattrs = {};
       drv = deriv;
     };
     expected = rec {
@@ -476,7 +478,9 @@ runTests {
       function = "<function>";
       functionArgs = "<function, args: {arg?, foo}>";
       list = "[ 3 4 ${function} [ false ] ]";
+      emptylist = "[ ]";
       attrs = "{ foo = null; \"foo bar\" = \"baz\"; }";
+      emptyattrs = "{ }";
       drv = "<derivation ${deriv.drvPath}>";
     };
   };