difftreelog
refactor nix-eval is now fully sync, parallelism should be explicit at the callsite
in: trunk
6 files changed
Cargo.lockdiffbeforeafterboth2070 "serde_json",2070 "serde_json",2071 "test-log",2071 "test-log",2072 "thiserror 2.0.16",2072 "thiserror 2.0.16",2073 "tokio",2074 "tokio-util",2075 "tracing",2073 "tracing",2076 "tracing-indicatif",2074 "tracing-indicatif",2077 "vte 0.15.0",2075 "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.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")
}