feat(tvix/eval): implement builtins.fromTOML

This allows parsing TOML from Tvix. We can enable the eval-okay-fromTOML
testcase from nix_tests. It uses the `toml` crate, and the serde
integration it brings with it.

Change-Id: Ic6f95aacf2aeb890116629b409752deac49dd655
Reviewed-on: https://cl.tvl.fyi/c/depot/+/7920
Autosubmit: flokli <flokli@flokli.de>
Reviewed-by: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
This commit is contained in:
Florian Klink 2023-01-24 15:54:29 +01:00 committed by clbot
parent 1facd889bb
commit e0b05c0fa6
8 changed files with 273 additions and 3 deletions

View file

@ -355,6 +355,13 @@ mod pure_builtins {
Ok(json_str.into())
}
#[builtin("fromTOML")]
fn builtin_from_toml(_: &mut VM, toml: Value) -> Result<Value, ErrorKind> {
let toml_str = toml.to_str()?;
toml::from_str(&toml_str).map_err(|err| err.into())
}
#[builtin("genericClosure")]
fn builtin_generic_closure(vm: &mut VM, input: Value) -> Result<Value, ErrorKind> {
let attrs = input.to_attrs()?;