Post-macOS Install Env Var settings for Zsh?

I installed nix on macOS recently, and was happily working through the Nix Pills series. I noticed that while I had the correct environment variables set like NIX_PATH, the install only looks for bash profiles to update, so my ~/.zshrc wasn’t touched. Consequently, after a macOS upgrade and reboot I’m missing those environment variables and their default values.

Can someone please enlightenment as to what environment variables should be set and to what values? I performed a multi-user deamon install. So I believe I need NIX_REMOTE=deamon, but I’m not sure where to point NIX_PATH to, or if I need to update PATH. Thanks.

On my arch Linux which is driven by zsh, I had to put some eval in the RC file to get it working, I’ll post the snippet when I’m back at my computer.

1 Like

Okay, I took a look, and it wasn’t eval, its been a simple sourcing of another file. I’m not sure what the suggested line from the installer was, but as I use a single config for all my machines, I modified it to look like this:

[[ -f /etc/profile.d/ ]] && . /etc/profile.d/

Perhaps identifying/locating that file and sourcing it from your ~/.zshrc works on MacOS as well?

Hrmm perhaps I’ll attempt a reinstall. Although that does sound like a Windows solution! :rofl: But it is quick and easy. The thing is, I don’t even have a /etc/profile.d/ directory, never mind a script.

In /etc I have zshrc.backup-before-nix but zshrc itself is identical to that file, so it looks like the install didn’t actually modify something it was intending to. I’ve got a ~/.bashrc and a ~/.bash_profile but I’ve never actually logged into a bash session because it’s a clean Catalina install so it’s straight into zsh. And even those bash config files are untouched.

It would be more useful if the installer could cater for the minor difference in using Zsh. #justsaying

Thanks for your help though.

As far as I remember, the Linux installer exactly told me what to add. That I then changed the line slightly iss unrelated.

I can’t check on a Mac though, as I do not own one.

Wait, wasn’t catalina the update that deleted about anything in / that wasn’t /Users or otherwise whitelisted by the operating system?

Dumping “nix” and “catalina” into my prefered search engine showed me straight this thread, perhaps its useful to you?

Saw that earlier. He was having issues with the daemon. There’s actually a long GitHub thread that addresses that issue and a few others, all of which I went through and got working during the install I did.

What I have discovered was missing, (and I can’t prove that is was this morning’s macOS upgrade I performed that deleted it, but I can’t see any other reason for the removal) was from the end of /etc/zsrch.

# Nix
if [ -e '/nix/var/nix/profiles/default/etc/profile.d/' ]; then
  . '/nix/var/nix/profiles/default/etc/profile.d/'
# End Nix

That script is responsible for setting all my nix environment variables, so that’s why I ended up in this state. I can only assume it was the macOS upgrade that overwrote it. I didn’t touch it. Didn’t even know it was there until today. :-/

Anyway, thanks for your help.

1 Like

If I were you I’d check the Previous System Versions folder (I think that’s what it’s called) to see if the install moved your old /etc/zshrc aside.

Edit: I think it may be /Users/Shared/Relocatable Items or something like that.