Fix NixOS detection

Use `/etc/os-release` instead of `/etc/NIXOS`.
The latter one does not exist on NixOS when using tmpfs as root.
This commit is contained in:
oxalica 2021-07-16 19:18:50 +08:00
parent a6470c7fa8
commit 919a8a5028
No known key found for this signature in database
GPG key ID: CED392DE0C483D00

View file

@ -580,7 +580,13 @@ class RustBuild(object):
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