Spaces:
Build error
Build error
| use std::process::Command; | |
| pub struct NixExecutor; | |
| impl NixExecutor { | |
| pub fn execute(cmd: &str, packages: Vec<&str>) -> String { | |
| // This runs the command inside a nix-shell with the requested packages | |
| let mut nix_cmd = Command::new("nix-shell"); | |
| nix_cmd.arg("-p").args(packages).arg("--run").arg(cmd); | |
| match nix_cmd.output() { | |
| Ok(output) => { | |
| let stdout = String::from_utf8_lossy(&output.stdout); | |
| let stderr = String::from_utf8_lossy(&output.stderr); | |
| format!("STDOUT: {}\nSTDERR: {}", stdout, stderr) | |
| } | |
| Err(e) => format!("Failed to execute Nix command: {}", e), | |
| } | |
| } | |
| } |