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.tomldiffbeforeafterboth1[package]2name = "nix-eval"3version.workspace = true4build = "build.rs"5edition.workspace = true6rust-version.workspace = true78[dependencies]9anyhow.workspace = true10nixlike.workspace = true11serde = { workspace = true, features = ["derive"] }12serde_json.workspace = true13thiserror.workspace = true14tokio = { workspace = true }15tokio-util.workspace = true16tracing.workspace = true1718cxx = "1.0.168"19itertools = "0.14.0"20test-log = { version = "0.2.18", features = ["trace"] }21tracing-indicatif = { version = "0.3.13", optional = true }22vte = { version = "0.15.0", features = ["ansi"] }2324[build-dependencies]25bindgen = "0.72.0"26cxx-build = "1.0.168"27pkg-config = "0.3.30"2829[features]30indicatif = ["dep:tracing-indicatif"]1[package]2name = "nix-eval"3version.workspace = true4build = "build.rs"5edition.workspace = true6rust-version.workspace = true78[dependencies]9anyhow.workspace = true10nixlike.workspace = true11serde = { workspace = true, features = ["derive"] }12serde_json.workspace = true13thiserror.workspace = true14tracing.workspace = true1516cxx = "1.0.168"17itertools = "0.14.0"18test-log = { version = "0.2.18", features = ["trace"] }19tracing-indicatif = { version = "0.3.13", optional = true }20vte = { version = "0.15.0", features = ["ansi"] }2122[build-dependencies]23bindgen = "0.72.0"24cxx-build = "1.0.168"25pkg-config = "0.3.30"2627[features]28indicatif = ["dep:tracing-indicatif"]crates/nix-eval/src/lib.rsdiffbeforeafterboth--- a/crates/nix-eval/src/lib.rs
+++ b/crates/nix-eval/src/lib.rs
@@ -750,7 +750,7 @@
})?;
Ok(out)
}
- pub async fn build(&self, output: &str) -> Result<PathBuf> {
+ pub fn build(&self, output: &str) -> Result<PathBuf> {
if !self.is_derivation() {
bail!("expected derivation to build")
}