Skip to content

Commit

Permalink
fix: more robust nixos check
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Jan 17, 2025
1 parent dd58346 commit 87763f8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion crates/svm-rs/src/install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ fn patch_for_nixos(bin: &Path) -> Result<(), SvmError> {
bin.display()
))
.output()
.expect("Failed to execute command");
.map_err(|e| SvmError::CouldNotPatchForNixOs(String::new(), e.to_string()))?;

match output.status.success() {
true => Ok(()),
Expand Down
5 changes: 4 additions & 1 deletion crates/svm-rs/src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ impl FromStr for Platform {
}

pub fn is_nixos() -> bool {
std::path::Path::new("/etc/NIXOS").exists()
cfg!(target_os = "linux")
&& (std::path::Path::new("/etc/nixos").exists()
|| std::path::Path::new("/etc/NIXOS").exists())
&& std::fs::read_to_string("/etc/os-release").is_ok_and(|s| s.contains("NixOS"))
}

/// Read the current machine's platform.
Expand Down

0 comments on commit 87763f8

Please sign in to comment.