diff options
author | Daniel Fullmer <danielrf12@gmail.com> | 2022-02-19 15:34:55 -0800 |
---|---|---|
committer | Jonathan Ringer <jonringer@users.noreply.github.com> | 2022-02-27 15:59:39 -0800 |
commit | 0a8007498f9dba0d5feb191d16317ffa85a9e698 (patch) | |
tree | 4219b864f6e62fee2852f4290be922eccca73319 /pkgs | |
parent | f4676c4cb05d63a23818d241d3c91be89ed29a83 (diff) |
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:.
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix | 2 | ||||
-rw-r--r-- | pkgs/build-support/build-fhs-userenv/env.nix | 2 | ||||
-rw-r--r-- | pkgs/shells/bash/5.1.nix | 3 | ||||
-rw-r--r-- | pkgs/top-level/all-packages.nix | 6 |
4 files changed, 11 insertions, 2 deletions
diff --git a/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix b/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix index 0051961d9f17a..1c4e2b607696b 100644 --- a/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix +++ b/pkgs/build-support/build-fhs-userenv-bubblewrap/env.nix @@ -41,7 +41,7 @@ let basePkgs = with pkgs; [ glibcLocales (if isMultiBuild then glibc_multi else glibc) - (toString gcc.cc.lib) bashInteractive coreutils less shadow su + (toString gcc.cc.lib) bashInteractiveFHS coreutils less shadow su gawk diffutils findutils gnused gnugrep gnutar gzip bzip2 xz ]; diff --git a/pkgs/build-support/build-fhs-userenv/env.nix b/pkgs/build-support/build-fhs-userenv/env.nix index 44c8adb06e186..abf577baa2d1f 100644 --- a/pkgs/build-support/build-fhs-userenv/env.nix +++ b/pkgs/build-support/build-fhs-userenv/env.nix @@ -45,7 +45,7 @@ let basePkgs = with pkgs; [ glibcLocales (if isMultiBuild then glibc_multi else glibc) - (toString gcc.cc.lib) bashInteractive coreutils less shadow su + (toString gcc.cc.lib) bashInteractiveFHS coreutils less shadow su gawk diffutils findutils gnused gnugrep gnutar gzip bzip2 xz ]; diff --git a/pkgs/shells/bash/5.1.nix b/pkgs/shells/bash/5.1.nix index 3a11858747e66..a30c9a4a5072b 100644 --- a/pkgs/shells/bash/5.1.nix +++ b/pkgs/shells/bash/5.1.nix @@ -10,6 +10,7 @@ , readline81 ? null , withDocs ? false , texinfo ? null +, forFHSEnv ? false }: with lib; @@ -39,8 +40,10 @@ stdenv.mkDerivation rec { NIX_CFLAGS_COMPILE = '' -DSYS_BASHRC="/etc/bashrc" -DSYS_BASH_LOGOUT="/etc/bash_logout" + '' + optionalString (!forFHSEnv) '' -DDEFAULT_PATH_VALUE="/no-such-path" -DSTANDARD_UTILS_PATH="/no-such-path" + '' + '' -DNON_INTERACTIVE_LOGIN_SHELLS -DSSH_SOURCE_BASHRC ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index daf09b98bcff5..a29312d19b3da 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -11550,6 +11550,12 @@ with pkgs; interactive = true; withDocs = true; }; + bashInteractiveFHS = callPackage ../shells/bash/5.1.nix { + binutils = stdenv.cc.bintools; + interactive = true; + withDocs = true; + forFHSEnv = true; + }; bash-completion = callPackage ../shells/bash/bash-completion { }; |