about summary refs log tree commit diff
path: root/tvix/eval/src/builtins
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-10-04T20·21+0300
committertazjin <tazjin@tvl.su>2022-10-07T14·24+0000
commit2478a6c5bac5d72f5a7a08709c84e471a1f3c763 (patch)
tree912b5b92614c74577ddcc4bf18b4881cee7323ff /tvix/eval/src/builtins
parent07e03498f26afbf647102d656c90d447f8586820 (diff)
feat(tvix/eval): coerce values to paths when importing r/5050
This enables the use of string paths (and, in the future,
derivations), as long as their string values represent an absolute
path.

Change-Id: I4b198efeb70415ed52f58bd1da6fa79a24dad14c
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6866
Reviewed-by: sterni <sternenseemann@systemli.org>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/builtins')
-rw-r--r--tvix/eval/src/builtins/impure.rs13
1 files changed, 1 insertions, 12 deletions
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs
index d73e5ccfa8f2..348963e89313 100644
--- a/tvix/eval/src/builtins/impure.rs
+++ b/tvix/eval/src/builtins/impure.rs
@@ -52,18 +52,7 @@ pub fn builtins_import(
         "import",
         &[true],
         move |mut args: Vec<Value>, vm: &mut VM| {
-            let path = match args.pop().unwrap() {
-                Value::Path(path) => path,
-                Value::String(_) => {
-                    return Err(ErrorKind::NotImplemented("importing from string-paths"))
-                }
-                other => {
-                    return Err(ErrorKind::TypeError {
-                        expected: "path or string",
-                        actual: other.type_of(),
-                    })
-                }
-            };
+            let path = super::coerce_value_to_path(&args.pop().unwrap(), vm)?;
 
             let contents =
                 std::fs::read_to_string(&path).map_err(|err| ErrorKind::ReadFileError {