about summary refs log tree commit diff
path: root/tvix/eval/src/compiler/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tvix/eval/src/compiler/mod.rs')
-rw-r--r--tvix/eval/src/compiler/mod.rs20
1 files changed, 8 insertions, 12 deletions
diff --git a/tvix/eval/src/compiler/mod.rs b/tvix/eval/src/compiler/mod.rs
index 11537e76b5c9..95de69487071 100644
--- a/tvix/eval/src/compiler/mod.rs
+++ b/tvix/eval/src/compiler/mod.rs
@@ -268,19 +268,15 @@ impl Compiler<'_> {
         let path = if raw_path.starts_with('/') {
             Path::new(&raw_path).to_owned()
         } else if raw_path.starts_with('~') {
-            let mut buf = match dirs::home_dir() {
-                Some(buf) => buf,
-                None => {
-                    self.emit_error(
-                        node,
-                        ErrorKind::PathResolution("failed to determine home directory".into()),
-                    );
-                    return;
-                }
-            };
+            return self.thunk(slot, node, move |c, _| {
+                // We assume that paths that home paths start with ~/ or fail to parse
+                // TODO: this should be checked using a parse-fail test.
+                debug_assert!(raw_path.len() > 2 && raw_path.starts_with("~/"));
 
-            buf.push(&raw_path);
-            buf
+                let home_relative_path = &raw_path[2..(raw_path.len())];
+                c.emit_constant(Value::UnresolvedPath(home_relative_path.into()), node);
+                c.push_op(OpCode::OpResolveHomePath, node);
+            });
         } else if raw_path.starts_with('.') {
             let mut buf = self.root_dir.clone();
             buf.push(&raw_path);