Recursive shells source the nix-daemon.sh on macOS due to /etc/zshrc #645

Open
opened 2025-01-23 22:53:45 +00:00 by jade · 1 comment
Owner

On macOS, presumably because everything is busted and terminal emulators start non-login shells without ever running the login shell (what), the Lix installer puts the sourcing of nix-daemon.sh in /etc/zshrc. This is a pawblem because this is then run in every further shell recursively, cluttering PATH with repeat entries of the Nix profiles.

Worse, though, this leads to the Nix profiles having precedence over stuff nix shell brings into scope.

This should be fixed by just adding export to the __ETC_PROFILE_NIX_SOURCED line, but I don't know if this is a bad idea. I just made my zshrc export that variable if present and it worked, but idk if it is the right solution.

On macOS, presumably because everything is busted and terminal emulators start non-login shells without ever running the login shell (what), the Lix installer puts the sourcing of `nix-daemon.sh` in `/etc/zshrc`. This is a pawblem because this is then run in every further shell recursively, cluttering PATH with repeat entries of the Nix profiles. Worse, though, this leads to the Nix profiles having precedence over stuff `nix shell` brings into scope. This should be fixed by just adding `export` to the `__ETC_PROFILE_NIX_SOURCED` line, but I don't know if this is a bad idea. I just made my zshrc export that variable if present and it worked, but idk if it is the right solution.
Author
Owner

Maybe something similar to this old code from prezto is the way to detect that it is a non-login shell that really is a login shell in disguise?

if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then
  source "${ZDOTDIR:-$HOME}/.zprofile"
fi
Maybe something similar to this old code from prezto is the way to detect that it is a non-login shell that really is a login shell in disguise? ```sh if [[ ( "$SHLVL" -eq 1 && ! -o LOGIN ) && -s "${ZDOTDIR:-$HOME}/.zprofile" ]]; then source "${ZDOTDIR:-$HOME}/.zprofile" fi ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#645
No description provided.