Since Nix 2.4 is just around the corner, I’m wondering if there exists now an official way to uninstall Nix from your macOS machine? I found some guides that do this, but they require multiple steps and a restart in between them, which is not very user friendly. Is it possible to make it easier, or automated somehow?
There is not an official tool yet (though I’m not sure an uninstall is necessary, in your case?)
This is very frequently requested. I’ve laid out roughly what I think it would take to be able to add an --uninstall
flag to the installer in Anyone up for picking at some Nix ~onboarding improvements? and Installer test suite? :) small project(s), high-leverage, help wanted but I am not aware of anyone currently working on any of them.
IIRC the reboot step is just for macOS to clean up the empty root /nix directory (some people get confused when they follow uninstall steps and still see the /nix directory, then throw a fit about the uninstall steps not working). I’ll give more detail than you probably need in case others land here via search:
- There’s no way around needing to reboot to have macOS remove the directory that I am aware of. It isn’t friendly, but it’s a system limitation we have to live with (unless/until Apple add some way for us to imperatively clean it up).
- You can skip the reboot step if you understand the consequences. If you:
- do not plan to reinstall, you understand that you’ll have a /nix directory hanging around until your next reboot.
- plan to then install Nix 2.3.x: go ahead and reboot. IIRC the 2.3.x installer will be confused by the presence of the /nix directory and the install will fail.
- plan to then install Nix 2.4.x (prerelease or release): you shouldn’t need to reboot. This installer should not be confused by the dangling directory.
I’m working on a tool that utilizes Nix under the hood and I want to install Nix for the user automatically. Of course should the user decide to uninstall my tool I would like it to clean up after itself, hence my interest in a proper uninstaller :).
Yes. It is a sore spot. I’d like to see it as well. As laid out in the discourse threads I linked, I think it’s definitely ~within reach. The installer is already a lot easier to work on than it was this time last year; a framework for building a proper test suite on it will go a long way towards making this easier to pick at.
For what it’s worth I put together a simple shell script that cleaned up my Mac after upgrading to Monterey via a clean installation and migration-assistant. In case anyone wants to use, or better still, improve it: nixbits/nix-uninstall.sh at 32f15fbb9927566a3052f7a7e0642508363399d6 · jacix/nixbits · GitHub
For additional clarity, there are now uninstall instructions in the manual @ Installing a Binary Distribution