forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,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; | ||
}; | ||
} |