Add debug output showing the nix commands being run.

This commit is contained in:
r-vdp 2023-10-12 12:20:15 +02:00
parent 371215e9d9
commit 16c145bdbb
No known key found for this signature in database

View file

@ -153,10 +153,12 @@ fn parse_nix_build_output(output: String) -> Result<StorePath> {
} }
fn run_nix_build(flake_uri: &str, nix_options: &NixOptions) -> Result<process::Output> { fn run_nix_build(flake_uri: &str, nix_options: &NixOptions) -> Result<process::Output> {
let output = nix_cmd(nix_options) let mut cmd = nix_cmd(nix_options);
.arg("build") cmd.arg("build").arg(flake_uri).arg("--json");
.arg(flake_uri)
.arg("--json") log::debug!("Running nix command: {cmd:?}");
let output = cmd
// Nix outputs progress info on stderr and the final output on stdout, // Nix outputs progress info on stderr and the final output on stdout,
// so we inherit and output stderr directly to the terminal, but we // so we inherit and output stderr directly to the terminal, but we
// capture stdout as the result of this call // capture stdout as the result of this call
@ -166,14 +168,16 @@ fn run_nix_build(flake_uri: &str, nix_options: &NixOptions) -> Result<process::O
} }
fn try_nix_eval(flake: &str, attr: &str, nix_options: &NixOptions) -> Result<bool> { fn try_nix_eval(flake: &str, attr: &str, nix_options: &NixOptions) -> Result<bool> {
let output = nix_cmd(nix_options) let mut cmd = nix_cmd(nix_options);
.arg("eval") cmd.arg("eval")
.arg(format!("{flake}#{FLAKE_ATTR}")) .arg(format!("{flake}#{FLAKE_ATTR}"))
.arg("--json") .arg("--json")
.arg("--apply") .arg("--apply")
.arg(format!("a: a ? \"{attr}\"")) .arg(format!("a: a ? \"{attr}\""));
.stderr(process::Stdio::inherit())
.output()?; log::debug!("Running nix command: {cmd:?}");
let output = cmd.stderr(process::Stdio::inherit()).output()?;
if output.status.success() { if output.status.success() {
let stdout = String::from_utf8(output.stdout)?; let stdout = String::from_utf8(output.stdout)?;
let parsed_output: bool = serde_json::from_str(&stdout)?; let parsed_output: bool = serde_json::from_str(&stdout)?;