Apple Borked my Nix!
Ok, so you've had nix (home-manager) working fine. Then Apple tells you it's time to update.
Ok. Reboot. Oops. It has now broken your Nix setup. Here's some stuff to work through. YMMV.
Note: This is what worked for me, who was just using nix + home-manager. The upgrade that I last did that caused all these issues was 12.3.X > 12.4
- Install instructions for OS X - it has a good summary of what is being done during install. https://nixos.org/manual/nix/stable/installation/installing-binary.html#macos-installation-a-namesect-macos-installation-change-store-prefixaa-namesect-macos-installation-encrypted-volumeaa-namesect-macos-installation-symlinkaa-namesect-macos-installation-recommended-notesa
- Actual install script https://github.com/NixOS/nix/blob/master/scripts/install-darwin-multi-user.sh
- Actual install script that works with setting up the Nix volume. https://raw.githubusercontent.com/NixOS/nix/master/scripts/create-darwin-volume.sh
Nix setup will modify your
/etc/zshrc. When OS X updates, it will sometimes restore the original
Check the bottom of your
etc/zshrc, you should see the following:
# 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
If it is NOT there, you want to add this back to the bottom of your
/etc/zshrc. Or you can try to future proof things a little, and add it to the top of your own
Nix Store volume check
From terminal try
diskutil list | grep Nix. You should see something like
7: APFS Volume Nix Store 10.1 GB disk3s7
So that means we have the volume. That last bit -
disk3s7 is the disk identifier. So then try
diskutil info disk3s7
Device Identifier: disk3s7 ... snip ... Volume Name: Nix Store Mounted: Yes Mount Point: /nix ... snip ... Volume UUID: 53E764A4-140E-4980-9EE2-39CB2404DAFF ... snip ... FileVault: Yes ... snip ...
No then you need to mount this. Probably means the auto-mount script is broken. Check if
/Library/LaunchDaemons/org.nixos.darwin-store.plist exists. If not, you can recreate it with the provided script - generate-volume-mount-plist.sh. This script is based off the nix install script
USE THE VOLUME UUID you found above. And use
unencrypted if your volume is FileVault: No.
NIX_VOLUME_UUID=53E764A4-140E-4980-9EE2-39CB2404DAFF NIX_VOLUME_STATE=encrypted ./generate-volume-mount-plist.sh
Check you have
/nix root level is missing, that means the mount point of your Nix Store got hosed. Let's rebuild it.
- Check for
/etc/synthetic.conf. If it exists, make sure you have an entry for
nix. If you don't have one, then you will need to set it up. It should be as simple as a file that just says:
- Check your
/etc/fstabfile. If it exists, check you have an entry for
/nix. If it doesn't, you will need to create it. WITH YOUR UUID you found earlier.
# # Warning - this file should only be modified with vifs(8) # # Failure to do so is unsupported and may be destructive. # UUID=53E764A4-140E-4980-9EE2-39CB2404DAFF /nix apfs rw,noauto,nobrowse,suid,owners