diff options
author | Griffin Smith <root@gws.fyi> | 2022-10-08T17·48-0400 |
---|---|---|
committer | grfn <grfn@gws.fyi> | 2022-10-08T19·02+0000 |
commit | b4d978cd6aeeac25897dc86b437fd2e96827626f (patch) | |
tree | e3017c05ee36156b92e4589065dd5f1466c2bd7e /tvix/eval/src/builtins/impure.rs | |
parent | 278bccc1ea3542610012177171234ad1c3c44dcf (diff) |
feat(tvix/tests): Import default.nix inside directory r/5068
This requires actually passing the source directory into `interpret` in the eval tests, but otherwise this is fairly straightforward - if we're trying to import a directory, just push `default.nix` onto it and import that instead. Change-Id: I0b7d4234f81977e78d14dfa651bf0cf9721017e5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/6893 Autosubmit: grfn <grfn@gws.fyi> Reviewed-by: sterni <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix/eval/src/builtins/impure.rs')
-rw-r--r-- | tvix/eval/src/builtins/impure.rs | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/tvix/eval/src/builtins/impure.rs b/tvix/eval/src/builtins/impure.rs index a1bcc602dc89..8e23003edb47 100644 --- a/tvix/eval/src/builtins/impure.rs +++ b/tvix/eval/src/builtins/impure.rs @@ -52,7 +52,10 @@ pub fn builtins_import( "import", &[true], move |mut args: Vec<Value>, vm: &mut VM| { - let path = super::coerce_value_to_path(&args.pop().unwrap(), vm)?; + let mut path = super::coerce_value_to_path(&args.pop().unwrap(), vm)?; + if path.is_dir() { + path.push("default.nix"); + } let contents = std::fs::read_to_string(&path).map_err(|err| ErrorKind::ReadFileError { |