forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtoTOML.nix
38 lines (36 loc) · 943 Bytes
/
toTOML.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
let
toTOMLInner = { data, path }:
if builtins.isAttrs data then
builtins.concatMap iter (builtins.attrNames set)
else if builtins.isFloat then
builtins.toString data
else if builtins.isInt then
builtins.toString data
else if builtins.isNull then
"null"
else if builtins.isString then
data # TODO: escape
else if builtins.isBool then
if data then "true" else "false"
else if builtins.isFunction then
builtins.throw "Can't convert a function to a string"
else if builtins.isList then
else if builtins.isPath then
builtins.toString data # TODO: escape
else builtins.throw "Not any valid data-type";
toTOML = data:
if builtins.isAttrs data then
toTOMLInner { inherit data; path = []; }
else
builtins.throw "Must be of type attrs";
in
{
testData = {
sub = {
sub2 = {
e = true;
};
};
e = true;
};
}