difftreelog
refactor nix-eval is now fully sync, parallelism should be explicit at the callsite
in: trunk
6 files changed
Cargo.lockdiffbeforeafterboth--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2070,8 +2070,6 @@
"serde_json",
"test-log",
"thiserror 2.0.16",
- "tokio",
- "tokio-util",
"tracing",
"tracing-indicatif",
"vte 0.15.0",
cmds/fleet/src/cmds/build_systems.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/build_systems.rs
+++ b/cmds/fleet/src/cmds/build_systems.rs
@@ -8,7 +8,7 @@
opts::FleetOpts,
};
use nix_eval::nix_go;
-use tokio::task::LocalSet;
+use tokio::task::{LocalSet, spawn_blocking};
use tracing::{Instrument, error, field, info, info_span, warn};
#[derive(Parser)]
@@ -34,7 +34,9 @@
// let action = Action::from(self.subcommand.clone());
let nixos = host.nixos_config().await?;
let drv = nix_go!(nixos.system.build[{ build_attr }]);
- let out_output = drv.build("out").await?;
+ let out_output = spawn_blocking(move || drv.build("out"))
+ .await
+ .expect("system derivation build should not panic")?;
// We already have system profiles for backups.
if !host.local {
cmds/fleet/src/cmds/secrets/mod.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/secrets/mod.rs
+++ b/cmds/fleet/src/cmds/secrets/mod.rs
@@ -19,7 +19,7 @@
use owo_colors::OwoColorize;
use serde::Deserialize;
use tabled::{Table, Tabled};
-use tokio::fs::read;
+use tokio::{fs::read, task::spawn_blocking};
use tracing::{Instrument, error, info, info_span, warn};
#[derive(Parser)]
@@ -288,7 +288,9 @@
let generator = nix_go!(call_package(generator)(Obj {}));
- let generator = generator.build("out").await?;
+ let generator = spawn_blocking(move || generator.build("out"))
+ .await
+ .expect("nix build shouldn't fail")?;
let generator = host.remote_derivation(&generator).await?;
let out_parent = host.mktemp_dir().await?;
cmds/fleet/src/cmds/tf.rsdiffbeforeafterboth--- a/cmds/fleet/src/cmds/tf.rs
+++ b/cmds/fleet/src/cmds/tf.rs
@@ -10,6 +10,7 @@
use tokio::{
fs::{self, create_dir_all},
process::Command,
+ task::spawn_blocking,
};
use tracing::debug;
@@ -38,7 +39,10 @@
debug!("generating terraform configs");
let system = &config.local_system;
let config = &config.config_field;
- let data: PathBuf = nix_go!(config.tf({ system })).build("out").await?;
+ let data = nix_go!(config.tf({ system }));
+ let data: PathBuf = spawn_blocking(move || data.build("out"))
+ .await
+ .expect("tf.json derivation should not fail")?;
let data = fs::read(&data).await?;
create_dir_all(&dir).await?;
crates/nix-eval/Cargo.tomldiffbeforeafterboth--- a/crates/nix-eval/Cargo.toml
+++ b/crates/nix-eval/Cargo.toml
@@ -11,8 +11,6 @@
serde = { workspace = true, features = ["derive"] }
serde_json.workspace = true
thiserror.workspace = true
-tokio = { workspace = true }
-tokio-util.workspace = true
tracing.workspace = true
cxx = "1.0.168"
crates/nix-eval/src/lib.rsdiffbeforeafterboth750 })?;750 })?;751 Ok(out)751 Ok(out)752 }752 }753 pub async fn build(&self, output: &str) -> Result<PathBuf> {753 pub fn build(&self, output: &str) -> Result<PathBuf> {754 if !self.is_derivation() {754 if !self.is_derivation() {755 bail!("expected derivation to build")755 bail!("expected derivation to build")756 }756 }