0

I use nix and home manager, zsh and tmux. My problem is that in tmux splits the nix command does not exist. I tried setting default shell in tmux to /bin/zsh -l sourcing files etc, I notice the PATH is just missing /nix/var/nix/profiles/default/bin:/Applications/Ghostty.app/Contents/MacOS

My .zshrc has

if [ -e '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' ]; then . '/nix/var/nix/profiles/default/etc/profile.d/nix-daemon.sh' fi 

I tested this in different terminals too - same story.

1
  • 1
    You can try adding a set -x in your .zshrc and see some debug output if it helps. Commented Oct 2 at 15:45

1 Answer 1

0

This is how I fixed a very similar problem in an armbian OS, append this line to .zshrc:

if [[ 1 -eq $__ETC_PROFILE_NIX_SOURCED ]] && ! type -p nix-shell > /dev/null; then unset __ETC_PROFILE_NIX_SOURCED && source /etc/profile.d/nix.sh; fi 

Assuming, you have the nix.sh file in profile.d. You might want to add the bits you already have in .zshrc, instead of the "source" command in my one liner. or maybe just remove that part and only use my code; If you also have the nix.sh file in the profile section.

Explanation: look at the first couple line of the nix-daemon.sh script:

# Only execute this file once per shell. # This file is tested by tests/installer/default.nix. if [ -n "${__ETC_PROFILE_NIX_SOURCED:-}" ]; then return; fi export __ETC_PROFILE_NIX_SOURCED=1 

It locks the script after the first run, using an environment variable, which, gets inherited to the tmux session you'll instantiate in that same environment, making further attempt to run this script in new shells, fail. So the fix, checks if we're in a situation where both the variable is set, and the nix-shell command isn't there to detect this faulty state, and unsets the lock and runs the source again.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.