about summary refs log tree commit diff
path: root/tvix/eval/src/builtins
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r--tvix/eval/src/builtins/mod.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 0b19a89aa316..cabdaf0070c7 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -100,6 +100,11 @@ fn pure_builtins() -> Vec<Builtin> {
 
             Ok(Value::List(NixList::construct(output.len(), output)))
         }),
+        Builtin::new("baseNameOf", &[true], |args: Vec<Value>, vm: &mut VM| {
+            let s = args[0].coerce_to_string(CoercionKind::Weak, vm)?;
+            let result: String = s.rsplit_once('/').map(|(_, x)| x).unwrap_or(&s).into();
+            Ok(result.into())
+        }),
         Builtin::new("bitAnd", &[true, true], |args: Vec<Value>, _: &mut VM| {
             Ok(Value::Integer(args[0].as_int()? & args[1].as_int()?))
         }),