diff options
| author | David Wood <david.wood@huawei.com> | 2021-10-01 12:41:18 +0000 |
|---|---|---|
| committer | David Wood <david.wood@huawei.com> | 2021-10-02 20:01:43 +0000 |
| commit | e552c0d86baebdf594b9cacebbcf5207e57207d5 (patch) | |
| tree | e8302f5ed832c07b68454b2a3c31d82f4896a32c /src/bootstrap | |
| parent | 4e4942dfa66667c0addfff8e0882a59b035d45ca (diff) | |
| download | rust-e552c0d86baebdf594b9cacebbcf5207e57207d5.tar.gz rust-e552c0d86baebdf594b9cacebbcf5207e57207d5.zip | |
bootstrap: add config option for nix patching
On NixOS systems, bootstrap will patch rustc used in bootstrapping after checking `/etc/os-release` (to confirm the current distribution is NixOS). However, when using Nix on a non-NixOS system, it can be desirable for bootstrap to patch rustc. In this commit, a `patch-binaries-for-nix` option is added to `config.toml`, which allows for user opt-in to bootstrap's Nix patching. Signed-off-by: David Wood <david.wood@huawei.com>
Diffstat (limited to 'src/bootstrap')
| -rw-r--r-- | src/bootstrap/bootstrap.py | 28 | ||||
| -rw-r--r-- | src/bootstrap/config.rs | 1 |
2 files changed, 17 insertions, 12 deletions
diff --git a/src/bootstrap/bootstrap.py b/src/bootstrap/bootstrap.py index 57ade88f733..05d7b0f611f 100644 --- a/src/bootstrap/bootstrap.py +++ b/src/bootstrap/bootstrap.py @@ -594,19 +594,23 @@ class RustBuild(object): if ostype != "Linux": return - # 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 + # If the user has asked binaries to be patched for Nix, then + # don't check for NixOS or `/lib`, just continue to the patching. + if self.get_toml('patch-binaries-for-nix', 'build') != '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(line.strip() == "ID=nixos" for line in f): + return + except FileNotFoundError: + return + if os.path.exists("/lib"): + return - # At this point we're pretty sure the user is running NixOS - nix_os_msg = "info: you seem to be running NixOS. Attempting to patch" + # At this point we're pretty sure the user is running NixOS or + # using Nix + nix_os_msg = "info: you seem to be using Nix. Attempting to patch" print(nix_os_msg, fname) # Only build `.nix-deps` once. diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs index 5706b8f9e7c..062820040dc 100644 --- a/src/bootstrap/config.rs +++ b/src/bootstrap/config.rs @@ -397,6 +397,7 @@ struct Build { install_stage: Option<u32>, dist_stage: Option<u32>, bench_stage: Option<u32>, + patch_binaries_for_nix: Option<bool>, } /// TOML representation of various global install decisions. |
