about summary refs log tree commit diff
path: root/tvix/eval/src/builtins/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/builtins/mod.rs')
-rw-r--r--tvix/eval/src/builtins/mod.rs21
1 files changed, 20 insertions, 1 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index c603264c1e27..47e4eea63d90 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -4,7 +4,7 @@
 //! available builtins in Nix.
 
 use std::cmp;
-use std::collections::{BTreeMap, HashMap};
+use std::collections::{BTreeMap, HashMap, HashSet};
 use std::path::PathBuf;
 
 use crate::{
@@ -362,6 +362,25 @@ fn pure_builtins() -> Vec<Builtin> {
             &[false, false],
             |args: Vec<Value>, vm: &mut VM| arithmetic_op!(&*args[0].force(vm)?, &*args[1].force(vm)?, *),
         ),
+        Builtin::new(
+            "removeAttrs",
+            &[true, true],
+            |args: Vec<Value>, _: &mut VM| {
+                let attrs = args[0].to_attrs()?;
+                let keys = args[1]
+                    .to_list()?
+                    .into_iter()
+                    .map(|v| v.to_str())
+                    .collect::<Result<HashSet<_>, _>>()?;
+                let mut res = BTreeMap::new();
+                for (k, v) in attrs.iter() {
+                    if !keys.contains(k) {
+                        res.insert(k.clone(), v.clone());
+                    }
+                }
+                Ok(Value::attrs(NixAttrs::from_map(res)))
+            },
+        ),
         Builtin::new("splitVersion", &[true], |args: Vec<Value>, _: &mut VM| {
             let s = args[0].to_str()?;
             let s = VersionPartsIter::new(s.as_str());