diff options
author | Florian Klink <flokli@flokli.de> | 2023-01-24T14·54+0100 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2023-01-25T07·49+0000 |
commit | e0b05c0fa6562bc7d3c87a66c6557ad74fdbbd8f (patch) | |
tree | 9777bf85c45f0527428c38974b102a0acf0455f2 /tvix/eval/src/builtins/mod.rs | |
parent | 1facd889bba724cf20ea14422ee1e57440b3e761 (diff) |
feat(tvix/eval): implement builtins.fromTOML r/5754
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
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index b1ea408a8ca4..4f3c93ec1451 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -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()?; |