diff --git a/src/cli/cmd/apply.rs b/src/cli/cmd/apply.rs index 81b4cab1..722e52b9 100644 --- a/src/cli/cmd/apply.rs +++ b/src/cli/cmd/apply.rs @@ -89,12 +89,6 @@ impl CommandExecute for ApplySubcommand { return Err(FhError::MissingProfile(profile_path).into()); } - tracing::debug!( - "Running: nix build --print-build-logs --max-jobs 0 --profile {} {}", - &profile_path, - &resolved_path.store_path, - ); - nix_command(&[ "build", "--print-build-logs", diff --git a/src/cli/cmd/mod.rs b/src/cli/cmd/mod.rs index 83edbc55..12fc3fbd 100644 --- a/src/cli/cmd/mod.rs +++ b/src/cli/cmd/mod.rs @@ -385,30 +385,24 @@ macro_rules! flakehub_url { async fn nix_command(args: &[&str]) -> Result<(), FhError> { command_exists("nix")?; + tracing::debug!( + "Running: nix build --extra-experimental-features 'nix-command-flakes' {}", + args.join(" ") + ); + let output = tokio::process::Command::new("nix") .args(["--extra-experimental-features", "nix-command flakes"]) .args(args) - .stdout(Stdio::inherit()) - .stderr(Stdio::inherit()) - .output() + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn()? + .wait_with_output() .await?; if output.status.success() { Ok(()) } else { - let mut s = String::new(); - - let stdout = String::from_utf8_lossy(&output.stdout).to_string(); - if !stdout.is_empty() { - s.push_str(stdout.trim()); - } - - let stderr = String::from_utf8_lossy(&output.stderr).to_string(); - if !stderr.is_empty() { - s.push_str(stderr.trim()); - } - - Err(FhError::FailedCommand(s)) + Err(FhError::FailedNixCommand) } } diff --git a/src/cli/error.rs b/src/cli/error.rs index 1c818c1c..f7e8db6e 100644 --- a/src/cli/error.rs +++ b/src/cli/error.rs @@ -1,7 +1,7 @@ #[derive(Debug, thiserror::Error)] pub(crate) enum FhError { - #[error("failed command: {0}")] - FailedCommand(String), + #[error("Nix command failed")] + FailedNixCommand, #[error("file error: {0}")] Filesystem(#[from] std::io::Error),