-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Description
Describe the bug
On a standard Debian 12.11 image, nix is not available inside tmux shells. This is because the Nix profile bin directories are not on the PATH, because the PATH gets reset in /etc/profile but __ETC_PROFILE_NIX_SOURCED is inherited.
Steps To Reproduce
- Start from a stock Debian Bookworm (current: 12.11) image.
sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --daemonwith default options.- Reboot for good measure.
- Observe that
nix --versionsucceeds on user's login shell, but not aftertmux.
Expected behavior
I expect nix to be available, and any other executables in the profile. However, they are not, as /home/$USER/.nix-profile/bin:/nix/var/nix/profiles/default/bin are not prepended to $PATH in the inner shell.
This is because in /etc/profile, PATH is reset as follows:
# /etc/profile: system-wide .profile file for the Bourne shell (sh(1))
# and Bourne compatible shells (bash(1), ksh(1), ash(1), ...).
if [ "$(id -u)" -eq 0 ]; then
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
else
PATH="/usr/local/bin:/usr/bin:/bin:/usr/local/games:/usr/games"
fi
export PATH
[…]
Yet __ETC_PROFILE_NIX_SOURCED=1 is inherited from the parent shell, so /etc/profile.d/nix.sh -> /nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh returns immediately.
Since this is a very basic setup (no customisations made to the stock Debian install), I just expect this to work.
Metadata
nix-env (Nix) 2.29.0