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
00axqwj2bc90ng4mz4vdzifcc4hjzaxb-compat-netbsd-9.2.drv
00ndzg2zv9wjxkjh9v7yv4plsg90fyxj-python3.9-shortuuid-1.0.1.drv
00qr10y7z2fcvrp9b2m46710nkjvj55z-update-autotools-gnu-config-scripts.sh
00sv2racjxv28m0mmr982ik8sbznx2c8-mailcap-2.1.53.drv
01895fqr82pmjqmw7ni7drl7j81m24my-ruby2.7.4-ttfunk-1.7.0.drv

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 nix-daemon.sh. 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.

2 Likes

Just added

# Nix
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
# End Nix

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

1 Like
Hosted by Flying Circus.