about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/Cargo.lock7
-rw-r--r--tvix/eval/Cargo.toml1
-rw-r--r--tvix/eval/src/compiler.rs16
3 files changed, 14 insertions, 10 deletions
diff --git a/tvix/eval/Cargo.lock b/tvix/eval/Cargo.lock
index c25839fdbb47..ecd0f05e409d 100644
--- a/tvix/eval/Cargo.lock
+++ b/tvix/eval/Cargo.lock
@@ -464,6 +464,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
 checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575"
 
 [[package]]
+name = "path-clean"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "ecba01bf2678719532c5e3059e0b5f0811273d94b397088b82e3bd0a78c78fdd"
+
+[[package]]
 name = "plotters"
 version = "0.3.3"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -834,6 +840,7 @@ version = "0.1.0"
 dependencies = [
  "criterion",
  "dirs",
+ "path-clean",
  "rnix",
  "rustyline",
  "smol_str",
diff --git a/tvix/eval/Cargo.toml b/tvix/eval/Cargo.toml
index b4cf60467541..836b5deed10b 100644
--- a/tvix/eval/Cargo.toml
+++ b/tvix/eval/Cargo.toml
@@ -10,6 +10,7 @@ rnix = "0.10.2"
 smol_str = "0.1"
 rustyline = "10.0.0"
 dirs = "4.0.0"
+path-clean = "0.1"
 
 [dev-dependencies]
 criterion = "0.3.6"
diff --git a/tvix/eval/src/compiler.rs b/tvix/eval/src/compiler.rs
index 63a02f68c013..c840056b48f3 100644
--- a/tvix/eval/src/compiler.rs
+++ b/tvix/eval/src/compiler.rs
@@ -13,6 +13,9 @@
 //! the code in this module, `debug_assert!` has been used to catch
 //! mistakes early during development.
 
+use path_clean::PathClean;
+use rnix;
+use rnix::types::{BinOpKind, EntryHolder, TokenWrapper, TypedNode, Wrapper};
 use std::path::{Path, PathBuf};
 
 use crate::chunk::Chunk;
@@ -21,9 +24,6 @@ use crate::opcode::{CodeIdx, OpCode};
 use crate::value::Value;
 use crate::warnings::{EvalWarning, WarningKind};
 
-use rnix;
-use rnix::types::{BinOpKind, EntryHolder, TokenWrapper, TypedNode, Wrapper};
-
 /// Represents the result of compiling a piece of Nix code. If
 /// compilation was successful, the resulting bytecode can be passed
 /// to the VM.
@@ -162,8 +162,6 @@ impl Compiler {
     }
 
     fn compile_path(&mut self, anchor: rnix::value::Anchor, path: String) -> EvalResult<()> {
-        // TODO(tazjin): C++ Nix does not resolve symlinks, but `fs::canonicalize` does.
-
         let path = match anchor {
             rnix::value::Anchor::Absolute => Path::new(&path).to_owned(),
 
@@ -189,11 +187,9 @@ impl Compiler {
             rnix::value::Anchor::Store => todo!("resolve <...> lookups at runtime"),
         };
 
-        let value =
-            Value::Path(path.canonicalize().map_err(|e| {
-                Error::PathResolution(format!("failed to canonicalise path: {}", e))
-            })?);
-
+        // TODO: Use https://github.com/rust-lang/rfcs/issues/2208
+        // once it is available
+        let value = Value::Path(path.clean());
         let idx = self.chunk.push_constant(value);
         self.chunk.push_op(OpCode::OpConstant(idx));