about summary refs log tree commit diff
path: root/tvix/eval/src/eval.rs
diff options
context:
space:
mode:
authorVincent Ambo <mail@tazj.in>2022-08-12T15·28+0300
committertazjin <tazjin@tvl.su>2022-08-28T11·02+0000
commit6fe5e2d75257504f0321e2e98b6fb675b716fe25 (patch)
treebf0549b862e8bdf25dda9e9b3aa05c16889b0ba5 /tvix/eval/src/eval.rs
parent1f8aad0ab41eec3db2e892bf80b6b76d54d36bbc (diff)
feat(tvix/eval): resolve relative path literals r/4519
Resolves relative paths (e.g. `./foo`) either relative to the location
of the Nix file, or relative to the working directory if none is
supplied.

Change-Id: I70ec574657b221b458015117a004b6e4a9c25a30
Reviewed-on: https://cl.tvl.fyi/c/depot/+/6185
Tested-by: BuildkiteCI
Reviewed-by: sterni <sternenseemann@systemli.org>
Diffstat (limited to 'tvix/eval/src/eval.rs')
-rw-r--r--tvix/eval/src/eval.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/tvix/eval/src/eval.rs b/tvix/eval/src/eval.rs
index 31280e4cd197..903708f108b3 100644
--- a/tvix/eval/src/eval.rs
+++ b/tvix/eval/src/eval.rs
@@ -1,8 +1,10 @@
+use std::path::PathBuf;
+
 use rnix::{self, types::TypedNode};
 
 use crate::{errors::EvalResult, value::Value};
 
-pub fn interpret(code: &str) -> EvalResult<Value> {
+pub fn interpret(code: &str, location: Option<PathBuf>) -> EvalResult<Value> {
     let ast = rnix::parse(code);
 
     let errors = ast.errors();
@@ -14,7 +16,7 @@ pub fn interpret(code: &str) -> EvalResult<Value> {
         println!("{}", ast.root().dump());
     }
 
-    let result = crate::compiler::compile(ast)?;
+    let result = crate::compiler::compile(ast, location)?;
     println!("code: {:?}", result.chunk);
 
     for warning in result.warnings {