diff options
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r-- | tvix/eval/src/builtins/mod.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs index d6b52e20a2a3..e7eb4e8bf953 100644 --- a/tvix/eval/src/builtins/mod.rs +++ b/tvix/eval/src/builtins/mod.rs @@ -436,6 +436,19 @@ fn pure_builtins() -> Vec<Builtin> { .map_err(Into::into) }), Builtin::new( + "mapAttrs", + &[true, true], + |args: Vec<Value>, vm: &mut VM| { + let attrs = args[1].to_attrs()?; + let mut res = BTreeMap::new(); + for (key, value) in attrs.as_ref() { + let value = vm.call_with(&args[0], [key.clone().into(), value.clone()])?; + res.insert(key.clone(), value); + } + Ok(Value::attrs(NixAttrs::from_map(res))) + }, + ), + Builtin::new( "match", &[true, true], |mut args: Vec<Value>, _: &mut VM| { |