summary refs log tree commit diff
path: root/lib/generators.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2018-04-25 15:04:30 +0200
committerProfpatsch <mail@profpatsch.de>2018-04-25 15:31:17 +0200
commitc84dad316a8d1eb0b5c2af0bd037c169096683ca (patch)
tree302d314a6959f91d3c766bf7f4a18e2d600f0b85 /lib/generators.nix
parent4340a1582ffbd90f19e42f1480d36e17c0b515c7 (diff)
downloadnixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.tar
nixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.tar.gz
nixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.tar.bz2
nixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.tar.lz
nixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.tar.xz
nixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.tar.zst
nixpkgs-c84dad316a8d1eb0b5c2af0bd037c169096683ca.zip
lib/generators: print paths without quotes & move function down
Diffstat (limited to 'lib/generators.nix')
-rw-r--r--lib/generators.nix26
1 files changed, 15 insertions, 11 deletions
diff --git a/lib/generators.nix b/lib/generators.nix
index d1a8f6bf8dc..c09384c00f5 100644
--- a/lib/generators.nix
+++ b/lib/generators.nix
@@ -143,18 +143,13 @@ rec {
        (This means fn is type Val -> String.) */
     allowPrettyValues ? false
   }@args: v: with builtins;
-    if      isInt      v then toString v
+    let     isPath   = v: typeOf v == "path";
+    in if   isInt      v then toString v
     else if isString   v then ''"${libStr.escape [''"''] v}"''
     else if true  ==   v then "true"
     else if false ==   v then "false"
-    else if null ==    v then "null"
-    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 "<λ>"
-                         else "<λ:{${showFnas}}>"
+    else if null  ==   v then "null"
+    else if isPath     v then toString v
     else if isList     v then "[ "
         + libStr.concatMapStringsSep " " (toPretty args) v
       + " ]"
@@ -163,12 +158,21 @@ rec {
       if attrNames v == [ "__pretty" "val" ] && allowPrettyValues
          then v.__pretty v.val
       # TODO: there is probably a better representation?
-      else if v ? type && v.type == "derivation" then "<δ>"
+      else if v ? type && v.type == "derivation" then
+        "<δ:${v.name}>"
+        # "<δ:${concatStringsSep "," (builtins.attrNames v)}>"
       else "{ "
           + libStr.concatStringsSep " " (libAttr.mapAttrsToList
               (name: value:
                 "${toPretty args name} = ${toPretty args value};") v)
         + " }"
-    else abort "generators.toPretty: should never happen (v = ${v})";
+    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 "<λ>"
+                         else "<λ:{${showFnas}}>"
+    else abort "toPretty: should never happen (v = ${v})";
 
 }