Skip to content

Commit

Permalink
try build
Browse files Browse the repository at this point in the history
  • Loading branch information
ToyVo committed Dec 1, 2024
1 parent 11554b4 commit d6b13d6
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ jobs:
cd $NH_FLAKE
nix flake init -t nix-darwin
cd $NH_CHECKOUT
nix run -L darwin switch -- --hostname simple --dry
nix run -L .#nh darwin switch -- --hostname simple --dry
name: Build Simple Nix Darwin Configuration
39 changes: 20 additions & 19 deletions src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,29 +63,30 @@ impl Command {

pub fn run(&self) -> Result<()> {
let cmd = if self.elevate {
let mut cmd = Exec::cmd("sudo");

// Check for if sudo has the preserve-env flag
#[cfg(target_os = "macos")]
let args = if Exec::cmd("sudo")
.args(&["--help"])
.stderr(Redirection::None)
.stdout(Redirection::Pipe)
.capture()?
.stdout_str()
.contains("--preserve-env") {
vec!["--set-home", "--preserve-env=PATH", "env"]
} else {
vec!["--set-home"]
};

#[cfg(not(target_os = "macos"))]
let args = vec![];

Exec::cmd("sudo").args(&args).arg(&self.command).args(&self.args)
cmd = cmd.args(
if Exec::cmd("sudo")
.args(&["--help"])
.stderr(Redirection::None)
.stdout(Redirection::Pipe)
.capture()?
.stdout_str()
.contains("--preserve-env") {
&["--set-home", "--preserve-env=PATH", "env"]
} else {
&["--set-home"]
}
);

cmd.arg(&self.command).args(&self.args)
} else {
Exec::cmd(&self.command).args(&self.args)
}
.stderr(Redirection::None)
.stdout(Redirection::None);
.stderr(Redirection::None)
.stdout(Redirection::None);

if let Some(m) = &self.message {
info!("{}", m);
Expand Down Expand Up @@ -186,7 +187,7 @@ impl Build {
.stderr(Redirection::Merge)
| Exec::cmd("nom").args(&["--json"])
}
.stdout(Redirection::None);
.stdout(Redirection::None);
debug!(?cmd);
cmd.join()
} else {
Expand Down

0 comments on commit d6b13d6

Please sign in to comment.