Skip to content

nix not on PATH in tmux on standard Debian 12.11 multi-user install #13255

@dnadlinger

Description

@dnadlinger

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

  1. Start from a stock Debian Bookworm (current: 12.11) image.
  2. sh <(curl --proto '=https' --tlsv1.2 -L https://nixos.org/nix/install) --daemon with default options.
  3. Reboot for good measure.
  4. Observe that nix --version succeeds on user's login shell, but not after tmux.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions