2019-07-02 12:50:32 +02:00
|
|
|
# some extra "builtins"
|
|
|
|
{ writeText, runCommand, remarshal }:
|
|
|
|
|
|
|
|
{
|
|
|
|
# Nix < 2.3 cannot parse all TOML files
|
|
|
|
# https://github.com/NixOS/nix/issues/2901
|
|
|
|
# can then be replaced with:
|
|
|
|
# readTOML = f: builtins.fromTOML (builtins.readFile f);
|
|
|
|
readTOML = f: builtins.fromJSON (builtins.readFile (runCommand "read-toml"
|
|
|
|
{ buildInputs = [ remarshal ]; }
|
|
|
|
''
|
|
|
|
remarshal \
|
|
|
|
-if toml \
|
|
|
|
-i ${f} \
|
|
|
|
-of json \
|
|
|
|
-o $out
|
|
|
|
''));
|
2019-07-04 16:34:33 +02:00
|
|
|
|
2019-07-02 12:50:32 +02:00
|
|
|
writeTOML = attrs: runCommand "write-toml"
|
|
|
|
{ buildInputs = [ remarshal ]; }
|
|
|
|
''
|
|
|
|
remarshal \
|
|
|
|
-if json \
|
|
|
|
-i ${writeText "toml-json" (builtins.toJSON attrs)} \
|
|
|
|
-of toml \
|
|
|
|
-o $out
|
|
|
|
'';
|
2019-07-04 16:34:33 +02:00
|
|
|
|
|
|
|
writeJSON = name: attrs: writeText name
|
|
|
|
(builtins.toJSON attrs);
|
2019-07-02 12:50:32 +02:00
|
|
|
}
|