Skip to content

nix-daemon.sh in zsh gives priority to system binaries on macOS #4169

@YorikSar

Description

@YorikSar

Describe the bug

After #3608 nix-daemon is being sourced from /etc/zshenv instead of /etc/zshrc which leads to system binaries getting priority over ones installed in Nix profile.

Steps To Reproduce

  1. Install Nix in daemon mode
  2. Open zsh shell
  3. Install git nix-env -iA nixpkgs.git
  4. Run git
  5. Observe request from the system to download and install Xcode utilities.

Expected behavior

Git should run from Nix.

nix-env --version output

nix-env (Nix) 2.3.7

Additional context

The order of files run by zsh is:

  • /etc/zshenv and ~/.zshenv
  • /etc/zprofile and ~/.zprofile
  • /etc/zshrc and ~/.zshrc

/etc/zprofile on macOS contains a call to /usr/libexec/path_helper that overrides PATH variable prepending all system paths from /etc/paths file and /etc/paths.d dir. Before #3608 nix-daemon.sh was sourced in /etc/zshrc after this call and Nix paths were in the front of the resulting PATH variable. After #3608 it is sourced in /etc/zshenv which leads to Nix paths ending up in the very end of PATH.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions