about summary refs log tree commit diff
path: root/tvix
diff options
context:
space:
mode:
Diffstat (limited to 'tvix')
-rw-r--r--tvix/eval/src/builtins/mod.rs17
1 files changed, 16 insertions, 1 deletions
diff --git a/tvix/eval/src/builtins/mod.rs b/tvix/eval/src/builtins/mod.rs
index 1ea23d49e632..02457340dcd1 100644
--- a/tvix/eval/src/builtins/mod.rs
+++ b/tvix/eval/src/builtins/mod.rs
@@ -18,7 +18,7 @@ use crate::{
 
 use crate::arithmetic_op;
 
-use self::versions::VersionPartsIter;
+use self::versions::{VersionPart, VersionPartsIter};
 
 pub mod versions;
 
@@ -213,6 +213,21 @@ fn pure_builtins() -> Vec<Builtin> {
             let a = args.pop().unwrap();
             arithmetic_op!(a, b, *)
         }),
+        Builtin::new("splitVersion", &[true], |args, _| {
+            let s = args[0].to_str()?;
+            let s = VersionPartsIter::new(s.as_str());
+
+            let parts = s
+                .map(|s| {
+                    Value::String(match s {
+                        // TODO(sterni): we should avoid converting back and forth here
+                        VersionPart::Number(n) => format!("{n}").into(),
+                        VersionPart::Word(w) => w.into(),
+                    })
+                })
+                .collect::<Vec<Value>>();
+            Ok(Value::List(NixList::construct(parts.len(), parts)))
+        }),
         Builtin::new("sub", &[true, true], |mut args, _| {
             let b = args.pop().unwrap();
             let a = args.pop().unwrap();