Accommodate tidy.
In addition: Incorporated some review feedback (namely, removed a useless initial assignment to True that was never read), and unified code a bit more between bootstrap.py and download.rs (by using the same variable name for the same concept).
This commit is contained in:
parent
3c6f4cc743
commit
ec2c95e093
2 changed files with 9 additions and 11 deletions
|
@ -650,26 +650,24 @@ class RustBuild(object):
|
||||||
if self.get_toml("patch-binaries-for-nix", "build") == "false":
|
if self.get_toml("patch-binaries-for-nix", "build") == "false":
|
||||||
return False
|
return False
|
||||||
|
|
||||||
# Assume we should fix until we see evidence that it is not NixOS
|
|
||||||
should_fix_retval = True
|
|
||||||
|
|
||||||
# Use `/etc/os-release` instead of `/etc/NIXOS`.
|
# Use `/etc/os-release` instead of `/etc/NIXOS`.
|
||||||
# The latter one does not exist on NixOS when using tmpfs as root.
|
# The latter one does not exist on NixOS when using tmpfs as root.
|
||||||
try:
|
try:
|
||||||
with open("/etc/os-release", "r") as f:
|
with open("/etc/os-release", "r") as f:
|
||||||
should_fix_retval = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f)
|
is_nixos = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"')
|
||||||
|
for ln in f)
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
should_fix_retval = False
|
is_nixos = False
|
||||||
|
|
||||||
# If not on NixOS, then warn if user seems to be atop Nix shell
|
# If not on NixOS, then warn if user seems to be atop Nix shell
|
||||||
if not should_fix_retval:
|
if not is_nixos:
|
||||||
in_nix_shell = os.getenv('IN_NIX_SHELL')
|
in_nix_shell = os.getenv('IN_NIX_SHELL')
|
||||||
if in_nix_shell:
|
if in_nix_shell:
|
||||||
print("The IN_NIX_SHELL environment variable is set to `{}`;".format(in_nix_shell),
|
print("The IN_NIX_SHELL environment variable is `{}`;".format(in_nix_shell),
|
||||||
"you may need to set `patch-binaries-for-nix=true` in your config.toml",
|
"you may need to set `patch-binaries-for-nix=true` in config.toml",
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
|
|
||||||
return should_fix_retval
|
return is_nixos
|
||||||
|
|
||||||
answer = self._should_fix_bins_and_dylibs = get_answer()
|
answer = self._should_fix_bins_and_dylibs = get_answer()
|
||||||
if answer:
|
if answer:
|
||||||
|
|
|
@ -109,8 +109,8 @@ impl Config {
|
||||||
let in_nix_shell = env::var("IN_NIX_SHELL");
|
let in_nix_shell = env::var("IN_NIX_SHELL");
|
||||||
if let Ok(in_nix_shell) = in_nix_shell {
|
if let Ok(in_nix_shell) = in_nix_shell {
|
||||||
eprintln!(
|
eprintln!(
|
||||||
"The IN_NIX_SHELL environment variable is set to `{in_nix_shell}`; \
|
"The IN_NIX_SHELL environment variable is `{in_nix_shell}`; \
|
||||||
you may need to set `patch-binaries-for-nix=true` in your config.toml"
|
you may need to set `patch-binaries-for-nix=true` in config.toml"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue