Uninstalling Nix on macOS

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 :).

1 Like

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.

1 Like

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: https://github.com/jacix/nixbits/blob/32f15fbb9927566a3052f7a7e0642508363399d6/nix-uninstall.sh


For additional clarity, there are now uninstall instructions in the manual @ Installing a Binary Distribution - Nix Reference Manual

1 Like

The instructions in the manual did not remove the nix volume (wrong name) but the script provided by @jacix worked nicely for me.

Skeptical of the wrong name part, unless maybe you manually set up Nix in the period between the release of Catalina and when the installer was finally fixed (and the fix released)? The volume has been named “Nix Store” for as long as the installer has actually supported creating it. (The script jacix linked deletes a volume named “Nix Store”.)

The first command in step 7 of the manual does assume the volume is mounted at /nix (in part because using the mountpoint can let it handle the older volumes people made themselves), but the rest of the step does detail what to do if it isn’t found:

If the output indicates that the command couldn’t remove the volume, you should make sure you don’t have an unmounted Nix Store volume. Look for a “Nix Store” volume in the output of the following command:

diskutil list

If you do see a “Nix Store” volume, delete it by re-running the diskutil deleteVolume command, but replace /nix with the store volume’s diskXsY identifier.

Sorry, it was not the name but the mount point. Still, the linked script worked w/o having to replace anything.

Thank you for the reply.

Someone else said lack of an Uninstall script was a sore point of Nix - yes, I’ll say.

For a piece of software thats so deeply invasive of your system, lack of an uninstaller is a great way to make yourself very unpopular. After being essentially ‘tricked’ into installing Nix as a stated dependency of ‘bob’ which was not the ‘bob’ I was looking for, I now have an unwanted freaking disk partition on my machine. I may not have a particular interest in Nix but I am a seasoned software developer so I say to you guys: think about the lifecycle of your software. Failing to give an uninstaller is a bad look and I’ll never use Nix or recommend it after this experience.

Thank you @jacix for sharing your unofficial uninstall script - this should really be officiallly supported and maintained.