Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add detailed uninstall section for macOS #6144

Merged
merged 4 commits into from
Mar 23, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 79 additions & 5 deletions doc/manual/src/installation/installing-binary.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ The installer will modify `/etc/bashrc`, and `/etc/zshrc` if they exist.
The installer will first back up these files with a `.backup-before-nix`
extension. The installer will also create `/etc/profile.d/nix.sh`.

You can uninstall Nix with the following commands:
## Uninstalling

### Linux

```console
sudo rm -rf /etc/profile/nix.sh /etc/nix /nix ~root/.nix-profile ~root/.nix-defexpr ~root/.nix-channels ~/.nix-profile ~/.nix-defexpr ~/.nix-channels
Expand All @@ -95,15 +97,87 @@ sudo systemctl stop nix-daemon.service
sudo systemctl disable nix-daemon.socket
sudo systemctl disable nix-daemon.service
sudo systemctl daemon-reload

# If you are on macOS, you will need to run:
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
```

There may also be references to Nix in `/etc/profile`, `/etc/bashrc`,
and `/etc/zshrc` which you may remove.

### macOS

1. Edit `/etc/zshrc` and `/etc/bashrc` to remove the lines sourcing
`nix-daemon.sh`, which should look like this:

```bash
# 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 these files haven't been altered since installing Nix you can simply put
the backups back in place:

```console
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
```

This will stop shells from sourcing the file and bringing everything you
installed using Nix in scope.

2. Stop and remove the Nix daemon services:

```console
sudo launchctl unload /Library/LaunchDaemons/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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the nix-darwin service, yeah? did you mean to use that one instead of the mount daemon?

(I was reading over all of this and thinking maybe we could get away with adding a few qualifiers to a few of these steps to say something like "You may not have X if you if you are running macOS Mojave (or earlier), or if you installed Nix before Y.")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, you're right of course. I was originally writing the instructions from a "I want to get rid of all things Nix," point of view but this would be more suited to the nix-darwin manual.

Maybe we can use the fstab step as the first differentiating step and add a note along the lines of "If you don't have this entry you probably have an older install on a pre-Catalina macOS, you won't have to do steps X, Y and Z and you should rm /nix instead?"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, similar to what you say in the very next comment but just localized to the first step where someone might notice a difference.

Alternatively we could make all the post-Catalina steps a sublist of a single step and then we can say to just skip the one step. Keeping them at the top-level list is slightly more flexible, the current order is based on not ending up with a broken setup at any point and going from easy to un-undo to harder to un-undo. However, I do think we could do all the post-Catalina specific stuff grouped.

```

This stops the Nix daemon and prevents it from being started next time you
boot the system.

3. Remove the `nixbld` group and the `_nixbuildN` users:

```console
sudo dscl . -delete /Groups/nixbld
for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done
```

This will remove all the build users that no longer serve a purpose.

4. 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 automatic
mounting of the Nix Store volume.

5. 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`.
This will prevent the creation of the empty `/nix` directory to provide a
mountpoint for the Nix Store volume.

6. Remove the files Nix added to your system:

```console
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 next.

7. Remove the Nix Store volume:

```console
sudo diskutil apfs deleteVolume /nix
```

This will remove the Nix Store volume and everything that was added to the
store.

The change to `/etc/synthetic.conf` will only take effect after a reboot but
you shouldn't have any traces of Nix left on your system.

# macOS Installation <a name="sect-macos-installation-change-store-prefix"></a><a name="sect-macos-installation-encrypted-volume"></a><a name="sect-macos-installation-symlink"></a><a name="sect-macos-installation-recommended-notes"></a>
<!-- Note: anchors above to catch permalinks to old explanations -->

Expand Down