about summary refs log tree commit diff
path: root/tvix/cli/src/main.rs
diff options
context:
space:
mode:
authorFlorian Klink <flokli@flokli.de>2024-02-13T16·05+0700
committerflokli <flokli@flokli.de>2024-02-17T04·49+0000
commite7815945df66b2893e0c424169dde8ddbeb0efe3 (patch)
tree19111e8cf88fc3b4fcb750bac853ec8cec19f9fe /tvix/cli/src/main.rs
parentda3ce74f7345b4a723b04545d99120827d60e890 (diff)
feat(tvix/cli): support configuring BuildService r/7533
Allow using a BUILD_SERVICE_ADDR env var, or cmdline args to configure
it. Still default to the dummy implementation.

Change-Id: I68f34f7b09eabef2b0491103857bbc798398ebfc
Reviewed-on: https://cl.tvl.fyi/c/depot/+/10846
Tested-by: BuildkiteCI
Reviewed-by: raitobezarius <tvl@lahfa.xyz>
Diffstat (limited to 'tvix/cli/src/main.rs')
-rw-r--r--tvix/cli/src/main.rs23
1 files changed, 20 insertions, 3 deletions
diff --git a/tvix/cli/src/main.rs b/tvix/cli/src/main.rs
index a678d01e5c38..da09ab878954 100644
--- a/tvix/cli/src/main.rs
+++ b/tvix/cli/src/main.rs
@@ -1,9 +1,8 @@
 use clap::Parser;
 use rustyline::{error::ReadlineError, Editor};
 use std::rc::Rc;
-use std::sync::Arc;
 use std::{fs, path::PathBuf};
-use tvix_build::buildservice::DummyBuildService;
+use tvix_build::buildservice;
 use tvix_eval::builtins::impure_builtins;
 use tvix_eval::observer::{DisassemblingObserver, TracingObserver};
 use tvix_eval::{EvalIO, Value};
@@ -67,6 +66,9 @@ struct Args {
 
     #[arg(long, env, default_value = "memory://")]
     path_info_service_addr: String,
+
+    #[arg(long, env, default_value = "dummy://")]
+    build_service_addr: String,
 }
 
 /// Interprets the given code snippet, printing out warnings, errors
@@ -91,11 +93,26 @@ fn interpret(code: &str, path: Option<PathBuf>, args: &Args, explain: bool) -> b
         })
         .expect("unable to setup {blob|directory|pathinfo}service before interpreter setup");
 
+    let build_service = tokio_runtime
+        .block_on({
+            let blob_service = blob_service.clone();
+            let directory_service = directory_service.clone();
+            async move {
+                buildservice::from_addr(
+                    &args.build_service_addr,
+                    blob_service.clone(),
+                    directory_service.clone(),
+                )
+                .await
+            }
+        })
+        .expect("unable to setup buildservice before interpreter setup");
+
     let tvix_store_io = Rc::new(TvixStoreIO::new(
         blob_service.clone(),
         directory_service.clone(),
         path_info_service.into(),
-        Arc::<DummyBuildService>::default(),
+        build_service.into(),
         tokio_runtime.handle().clone(),
     ));