about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--tvix/eval/src/main.rs16
1 files changed, 7 insertions, 9 deletions
diff --git a/tvix/eval/src/main.rs b/tvix/eval/src/main.rs
index efd4d14c3b1a..0fbc7ad9a620 100644
--- a/tvix/eval/src/main.rs
+++ b/tvix/eval/src/main.rs
@@ -1,7 +1,4 @@
-use std::{
-    fs,
-    path::{Path, PathBuf},
-};
+use std::{fs, path::PathBuf};
 
 use clap::Parser;
 use rustyline::{error::ReadlineError, Editor};
@@ -18,17 +15,18 @@ struct Args {
 fn main() {
     let args = Args::parse();
 
-    if let Some(file) = &args.script {
+    if let Some(file) = args.script {
         run_file(file, args.eval_options)
     } else {
         run_prompt(args.eval_options)
     }
 }
 
-fn run_file(file: &Path, eval_options: tvix_eval::Options) {
-    let contents = fs::read_to_string(file).expect("failed to read the input file");
-    let path = Path::new(file).to_owned();
-
+fn run_file(mut path: PathBuf, eval_options: tvix_eval::Options) {
+    if path.is_dir() {
+        path.push("default.nix");
+    }
+    let contents = fs::read_to_string(&path).expect("failed to read the input file");
     match tvix_eval::interpret(&contents, Some(path), eval_options) {
         Ok(result) => println!("=> {} :: {}", result, result.type_of()),
         Err(err) => eprintln!("{}", err),