Nix-* commands missing after macOS 12.1 version upgrade

I just updated my macOS system version from 12.0 to 12.1 (21C52), and it seems like nix and home-manager have been mysteriously “uninstalled”:

❯ which nix-shell
nix-shell not found

Thankfully my nix store has been preserved however:

❯ ls /nix/store | head -n 5

How do I “re-enable” nix now?

Maybe the upgrade reset your /etc/zshrc. Is Nix mentioned anywhere there?

If not, look for the relevant profile script, I think in in /nix/var/nix/profiles/default/etc/profile.d. I think it may be called Normally on macOS, /etc/bashrc and /etc/zshrc check if that file exists in an if block, then source it if it does.

The other thing you might have to set back up if it got nuked is the launchd entry that automatically starts the Nix daemon

Is there a convenient way to just get back up to speed? Eg could I just run the installer again to safely get things back to normal?

Here’s my /etc/zshrc btw: zshrc · GitHub. No nix anything in there AFAICT.

The os updates overwrite the zshrc. macOS updates often break nix installation (updates replace path-hooks on multi-user install) · Issue #3616 · NixOS/nix · GitHub

Just append the same thing that is most-likely appended to your bashrc.


Just added

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

to the end of my /etc/zshrc and that seemed to do the trick! Thanks @abathur!


Just had this happen again with the upgrade to macOS 12.2.1.

And it will happen with the next update well, as Apple doesn’t respect your wishes.

Perhaps they leave your user configuration intact? Can’t you source the nix profile script from there?

1 Like

This happens when I upgrade to macOS 12.6.1
Your solution solved it. :star_struck:

1 Like

Sorry for the necro but just wanted to add that if you installed Nix via Determinate Systems’ installer, the installer actually has a specific command for this:

/nix/nix-installer repair

repair: Update the shell profiles to make Nix usable after system upgrades

1 Like