lib.toC: admit derivations

This commit is contained in:
tv 2016-02-14 12:28:56 +01:00
parent 9a7b7dc509
commit c1a9a89c9a

View File

@ -26,11 +26,15 @@ let out = rec {
shell = import ./shell.nix { inherit lib; };
tree = import ./tree.nix { inherit lib; };
toC = x: {
toC = x: let
type = typeOf x;
reject = throw "cannot convert ${type}";
in {
list = "{ ${concatStringsSep ", " (map toC x)} }";
null = "NULL";
set = if isDerivation x then toJSON x else reject;
string = toJSON x; # close enough
}.${typeOf x};
}.${type} or reject;
subdirsOf = path:
mapAttrs (name: _: path + "/${name}")