about summary refs log tree commit diff
path: root/tvix/eval
diff options
context:
space:
mode:
authorVincent Ambo <tazjin@tvl.su>2024-02-20T11·30+0700
committerclbot <clbot@tvl.fyi>2024-02-20T12·13+0000
commite839116e5c583a82d145e5dca336964e6569d487 (patch)
tree1686b375620f1c9f59afa6ebfae0f1c8bf1f947c /tvix/eval
parentf40ff1737e829fb98a01951794eb1f3624cd3cad (diff)
fix(tvix/eval): make path resolution work by default in impure mode r/7574
The previous behaviour (enabling `import`, but not allowing e.g.
`<nixpkgs/lib>` to resolve) was very confusing.

Now imports from NIX_PATH become enabled by default, unless the user
already overrode that behaviour with something else by setting
`Evaluation::nix_path` manually.

Change-Id: Iad970beb633d9887be4b185b01e6f5858d81bea3
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10993
Reviewed-by: flokli <flokli@flokli.de>
Autosubmit: tazjin <tazjin@tvl.su>
Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval')
-rw-r--r--tvix/eval/src/lib.rs6
1 files changed, 6 insertions, 0 deletions
diff --git a/tvix/eval/src/lib.rs b/tvix/eval/src/lib.rs
index 9c298df60a8f..8ce37de42732 100644
--- a/tvix/eval/src/lib.rs
+++ b/tvix/eval/src/lib.rs
@@ -171,6 +171,12 @@ impl<'co, 'ro> Evaluation<'co, 'ro, Box<dyn EvalIO>> {
         self.io_handle = io.unwrap_or_else(|| Box::new(StdIO) as Box<dyn EvalIO>);
         self.enable_import = true;
         self.builtins.extend(builtins::impure_builtins());
+
+        // Make `NIX_PATH` resolutions work by default, unless the
+        // user already overrode this with something else.
+        if self.nix_path.is_none() {
+            self.nix_path = std::env::var("NIX_PATH").ok();
+        }
     }
 
     #[cfg(feature = "impure")]