about summary refs log tree commit diff
diff options
context:
space:
mode:
authoroxalica <oxalicc@pm.me>2021-07-16 19:18:50 +0800
committeroxalica <oxalicc@pm.me>2021-07-21 00:38:41 +0800
commit919a8a5028e4b94370e9c3f6b19cda48f9c97f7b (patch)
tree3aaa6bbb914681e6fdd8d16955c2bed17cfaf923
parenta6470c7fa8a511cfbcf9e9d3e1ab6779ac661edb (diff)
Fix NixOS detection
Use `/etc/os-release` instead of `/etc/NIXOS`.
The latter one does not exist on NixOS when using tmpfs as root.
-rw-r--r--src/bootstrap/bootstrap.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py
index f9904cb610d..1c5e9d5d837 100644
--- a/src/bootstrap/bootstrap.py
+++ b/src/bootstrap/bootstrap.py
@@ -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