summaryrefslogtreecommitdiffstats
path: root/krebs/4lib
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-02-14 12:28:56 +0100
committertv <tv@krebsco.de>2016-02-14 12:28:56 +0100
commitc1a9a89c9a211b48bb04f1862a216bb5d444c3a2 (patch)
tree1ac975b3a7d400f191800a46b5f30fe9433214ab /krebs/4lib
parent9a7b7dc5091b0af43fe9d6620f236878f93b3225 (diff)
lib.toC: admit derivations
Diffstat (limited to 'krebs/4lib')
-rw-r--r--krebs/4lib/default.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/krebs/4lib/default.nix b/krebs/4lib/default.nix
index 4d7e0b54..d5b6d03a 100644
--- a/krebs/4lib/default.nix
+++ b/krebs/4lib/default.nix
@@ -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}")