Skip to content

Commit

Permalink
Rollup merge of rust-lang#87187 - oxalica:fix-nixos-detect, r=nagisa
Browse files Browse the repository at this point in the history
Fix NixOS detection

Use `/etc/os-release` instead of `/etc/NIXOS` for detection.
The latter one does not exist on NixOS when using tmpfs as root.
  • Loading branch information
Dylan-DPC authored Jul 21, 2021
2 parents 2d05209 + 919a8a5 commit 2cc7e85
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,13 @@ def fix_bin_or_dylib(self, fname):
if ostype != "Linux":
return

if not os.path.exists("/etc/NIXOS"):
# Use `/etc/os-release` instead of `/etc/NIXOS`.
# The latter one does not exist on NixOS when using tmpfs as root.
try:
with open("/etc/os-release", "r") as f:
if not any(line.strip() == "ID=nixos" for line in f):
return
except FileNotFoundError:
return
if os.path.exists("/lib"):
return
Expand Down

0 comments on commit 2cc7e85

Please sign in to comment.