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!

1 Like
Hosted by Flying Circus.