Optionally dump stdout
This commit is contained in:
parent
d2cfece806
commit
1fc075a5b7
|
@ -28,7 +28,7 @@ impl EvalChecker {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(&self, path: &Path) -> Result<File, File> {
|
pub fn execute(&self, path: &Path) -> Result<File, File> {
|
||||||
self.nix.safely(&self.cmd, path, self.args.clone())
|
self.nix.safely(&self.cmd, path, self.args.clone(), false)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cli_cmd(&self) -> String {
|
pub fn cli_cmd(&self) -> String {
|
||||||
|
|
|
@ -40,18 +40,27 @@ impl Nix {
|
||||||
attrargs.push(attr);
|
attrargs.push(attr);
|
||||||
}
|
}
|
||||||
|
|
||||||
return self.safely("nix-build", nixpkgs, attrargs);
|
return self.safely("nix-build", nixpkgs, attrargs, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn safely(&self, cmd: &str, nixpkgs: &Path, args: Vec<String>) -> Result<File,File> {
|
pub fn safely(&self, cmd: &str, nixpkgs: &Path, args: Vec<String>, keep_stdout: bool) -> Result<File,File> {
|
||||||
let mut nixpath = OsString::new();
|
let mut nixpath = OsString::new();
|
||||||
nixpath.push("nixpkgs=");
|
nixpath.push("nixpkgs=");
|
||||||
nixpath.push(nixpkgs.as_os_str());
|
nixpath.push(nixpkgs.as_os_str());
|
||||||
|
|
||||||
let stdout = tempfile().expect("Fetching a stdout tempfile");
|
let stderr = tempfile().expect("Fetching a stderr tempfile");
|
||||||
let stderr = stdout.try_clone().expect("Cloning stdout for stderr");
|
|
||||||
let mut reader = stderr.try_clone().expect("Cloning stderr to the reader");
|
let mut reader = stderr.try_clone().expect("Cloning stderr to the reader");
|
||||||
|
|
||||||
|
let stdout: Stdio;
|
||||||
|
|
||||||
|
if keep_stdout {
|
||||||
|
let stdout_fd = stderr.try_clone().expect("Cloning stderr for stdout");
|
||||||
|
stdout = Stdio::from(stdout_fd);
|
||||||
|
} else {
|
||||||
|
stdout = Stdio::null();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
let status = Command::new(cmd)
|
let status = Command::new(cmd)
|
||||||
.env_clear()
|
.env_clear()
|
||||||
.current_dir(nixpkgs)
|
.current_dir(nixpkgs)
|
||||||
|
|
|
@ -436,7 +436,8 @@ impl Stdenvs {
|
||||||
String::from("."),
|
String::from("."),
|
||||||
String::from("-A"),
|
String::from("-A"),
|
||||||
String::from("stdenv"),
|
String::from("stdenv"),
|
||||||
]
|
],
|
||||||
|
false
|
||||||
);
|
);
|
||||||
|
|
||||||
println!("{:?}", result);
|
println!("{:?}", result);
|
||||||
|
|
Loading…
Reference in a new issue