Uninstall nix on MacOS
To uninstall nix on Mac OS complete the following steps:
Step 1: Edit /etc/zshrc and etc/.bashrc and remove the following lines sourcing nix-daemon.sh
#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 the two files zshrc and bashrc haven't been altered since installing Nix you can simply put them as back-ups. The latest installer also runs preliminary checks to verify.
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
sudo mv etc/bashrc.backup-before-nix /etc/bashrc
Step 2: Edit fstab using sudo vifs to remove the line mounting the Nix store volume on /nix, which looks like this, LABEL=Nix\040stORE /nix apfs rw,nobrowse. This will prevent the automatic mounting of the Nix store volume
Step 3: Edit /etc/synthetic.conf to remove the nix line. If this is the only line in the file you can remove it entirely, sudo rm /etc/synthetic.conf.
Step 4: Stop and remove the Nix daemon service:
sudo launchctl unload /Library/LaunchDaemon/org.nixos.nix-daemon.plist
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo launchctl unload /Library/LaunchDaemons/org.nixos.activate-system.plist
sudo rm /Library/LaunchDaemons/org.nixos.activate-system.plist
This stops the nix service and prevents it from starting
Step 5: Remove the files Nix added to the system
sudo rm -rf /etc/nix /var/root/.nix-profile /var/root/.nix-defexpr /var/root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels
This gets rid of any data Nix may have created except for the store which is removed later
Step 6: Remove the nixbld group and the _nixbuildN users:
sudo dscl . delete /Groups/nixbld
for i in $(seq 1 32); do sudo dscl . -delete /Users/_nixbld$i; done
Step 7: Remove the Nix store volume
sudo diskutil apfs deleteVolume /nix
sudo rm -rf /nix/
This will remove everything that was added to the nix store.
Step 8: Reboot the OS