From 1f69d4d1ebb5ecb0ba51c1956df7dac730ae6d87 Mon Sep 17 00:00:00 2001 From: Marc Weber Date: Tue, 2 Dec 2008 12:26:12 +0000 Subject: [PATCH] enhancing whatis trace function svn path=/nixpkgs/trunk/; revision=13541 --- pkgs/lib/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/lib/default.nix b/pkgs/lib/default.nix index fe5b7fb1427..e03d0be27d6 100644 --- a/pkgs/lib/default.nix +++ b/pkgs/lib/default.nix @@ -566,10 +566,11 @@ rec { # this can help debug your code as well - designed to not produce thousands of lines traceWhatis = x : __trace (whatis x) x; traceMarked = str: x: __trace (str + (whatis x)) x; - whatis = x : + attrNamesToStr = a : concatStringsSep "; " (map (x : "${x}=") (__attrNames a)); + whatis = x : if (__isAttrs x) then - if (x ? outPath) then "x is a derivation with name ${x.name}" - else "x is an attr set with attributes ${builtins.toString (__attrNames x)}" + if (x ? outPath) then "x is a derivation, name ${if x ? name then x.name else ""}, { ${attrNamesToStr x} }" + else "x is attr set { ${attrNamesToStr x} }" else if (__isFunction x) then "x is a function" else if (x == []) then "x is an empty list" else if (__isList x) then "x is a list, first item is : ${whatis (__head x)}"