Skip to content

Commit 3ec97ff

Browse files
committed
fix: more robust nixos check
1 parent dd58346 commit 3ec97ff

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

crates/svm-rs/src/install.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ fn patch_for_nixos(bin: &Path) -> Result<(), SvmError> {
212212
bin.display()
213213
))
214214
.output()
215-
.expect("Failed to execute command");
215+
.map_err(|e| SvmError::CouldNotPatchForNixOs(String::new(), e.to_string()))?;
216216

217217
match output.status.success() {
218218
true => Ok(()),

crates/svm-rs/src/platform.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ impl FromStr for Platform {
4343
}
4444

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

4951
/// Read the current machine's platform.

0 commit comments

Comments
 (0)