Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Always use os-release rather than /lib to detect NixOS (bootstrap) #115090

Merged
merged 1 commit into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 2 additions & 7 deletions src/bootstrap/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,22 +644,17 @@ def get_answer():
return False

# If the user has asked binaries to be patched for Nix, then
# don't check for NixOS or `/lib`.
# don't check for NixOS.
if self.get_toml("patch-binaries-for-nix", "build") == "true":
return True

# 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(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f):
return False
return any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f)
except FileNotFoundError:
return False
if os.path.exists("/lib"):
return False

return True

answer = self._should_fix_bins_and_dylibs = get_answer()
if answer:
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/download.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ impl Config {
matches!(l.trim(), "ID=nixos" | "ID='nixos'" | "ID=\"nixos\"")
}),
};
is_nixos && !Path::new("/lib").exists()
is_nixos
});
if val {
eprintln!("info: You seem to be using Nix.");
Expand Down