Skip to content

Commit ec2c95e

Browse files
committed
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).
1 parent 3c6f4cc commit ec2c95e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

src/bootstrap/bootstrap.py

+7-9
Original file line numberDiff line numberDiff line change
@@ -650,26 +650,24 @@ def get_answer():
650650
if self.get_toml("patch-binaries-for-nix", "build") == "false":
651651
return False
652652

653-
# Assume we should fix until we see evidence that it is not NixOS
654-
should_fix_retval = True
655-
656653
# Use `/etc/os-release` instead of `/etc/NIXOS`.
657654
# The latter one does not exist on NixOS when using tmpfs as root.
658655
try:
659656
with open("/etc/os-release", "r") as f:
660-
should_fix_retval = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"') for ln in f)
657+
is_nixos = any(ln.strip() in ("ID=nixos", "ID='nixos'", 'ID="nixos"')
658+
for ln in f)
661659
except FileNotFoundError:
662-
should_fix_retval = False
660+
is_nixos = False
663661

664662
# If not on NixOS, then warn if user seems to be atop Nix shell
665-
if not should_fix_retval:
663+
if not is_nixos:
666664
in_nix_shell = os.getenv('IN_NIX_SHELL')
667665
if in_nix_shell:
668-
print("The IN_NIX_SHELL environment variable is set to `{}`;".format(in_nix_shell),
669-
"you may need to set `patch-binaries-for-nix=true` in your config.toml",
666+
print("The IN_NIX_SHELL environment variable is `{}`;".format(in_nix_shell),
667+
"you may need to set `patch-binaries-for-nix=true` in config.toml",
670668
file=sys.stderr)
671669

672-
return should_fix_retval
670+
return is_nixos
673671

674672
answer = self._should_fix_bins_and_dylibs = get_answer()
675673
if answer:

src/bootstrap/download.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ impl Config {
109109
let in_nix_shell = env::var("IN_NIX_SHELL");
110110
if let Ok(in_nix_shell) = in_nix_shell {
111111
eprintln!(
112-
"The IN_NIX_SHELL environment variable is set to `{in_nix_shell}`; \
113-
you may need to set `patch-binaries-for-nix=true` in your config.toml"
112+
"The IN_NIX_SHELL environment variable is `{in_nix_shell}`; \
113+
you may need to set `patch-binaries-for-nix=true` in config.toml"
114114
);
115115
}
116116
}

0 commit comments

Comments
 (0)