bash: use default PATH in FHS environments
If bash is executed within an environment where PATH is not set, it uses
the DEFAULT_PATH_VALUE compiled into bash to set PATH. In nixpkgs we set
this to /no-such-path by default. This makes sense in a nixpkgs/NixOS
environment since paths like /bin or /usr/bin should not be used.
However, when bash is used inside an FHS environment, this produces
results that differ from distributions which follow the FHS standard.
Before this change:
$ steam-run env -i /bin/bash -c 'echo $PATH'
/no-such-path
After this change:
$ steam-run env -i /bin/bash -c 'echo $PATH'
/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin:.
commit0a8007498f9dba0d5feb191d16317ffa85a9e698
authorDaniel Fullmer <danielrf12@gmail.com>
dateSat 19 Feb 2022, 15:34 (5 years ago)
parentf4676c4
pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix+1−1
@@ -41,7 +41,7 @@ let
4141 basePkgs = with pkgs;
4242 [ glibcLocales
4343 (if isMultiBuild then glibc_multi else glibc)
44− (toString gcc.cc.lib) bashInteractive coreutils less shadow su
44+ (toString gcc.cc.lib) bashInteractiveFHS coreutils less shadow su
4545 gawk diffutils findutils gnused gnugrep
4646 gnutar gzip bzip2 xz
4747 ];
pkgs/build-support/build-fhs-userenv/env.nix+1−1
@@ -45,7 +45,7 @@ let
4545 basePkgs = with pkgs;
4646 [ glibcLocales
4747 (if isMultiBuild then glibc_multi else glibc)
48− (toString gcc.cc.lib) bashInteractive coreutils less shadow su
48+ (toString gcc.cc.lib) bashInteractiveFHS coreutils less shadow su
4949 gawk diffutils findutils gnused gnugrep
5050 gnutar gzip bzip2 xz
5151 ];
pkgs/shells/bash/5.1.nix+3
@@ -10,6 +10,7 @@
1010, readline81 ? null
1111, withDocs ? false
1212, texinfo ? null
13+, forFHSEnv ? false
1314}:
1415
1516with lib;
@@ -39,8 +40,10 @@ stdenv.mkDerivation rec {
3940 NIX_CFLAGS_COMPILE = ''
4041 -DSYS_BASHRC="/etc/bashrc"
4142 -DSYS_BASH_LOGOUT="/etc/bash_logout"
43+ '' + optionalString (!forFHSEnv) ''
4244 -DDEFAULT_PATH_VALUE="/no-such-path"
4345 -DSTANDARD_UTILS_PATH="/no-such-path"
46+ '' + ''
4447 -DNON_INTERACTIVE_LOGIN_SHELLS
4548 -DSSH_SOURCE_BASHRC
4649 '';
pkgs/top-level/all-packages.nix+6
@@ -11550,6 +11550,12 @@ with pkgs;
1155011550 interactive = true;
1155111551 withDocs = true;
1155211552 };
11553+ bashInteractiveFHS = callPackage ../shells/bash/5.1.nix {
11554+ binutils = stdenv.cc.bintools;
11555+ interactive = true;
11556+ withDocs = true;
11557+ forFHSEnv = true;
11558+ };
1155311559
1155411560 bash-completion = callPackage ../shells/bash/bash-completion { };
1155511561