We will perform a multi-user install, putting the Nix store on an APFS volume without FileVault encryption. Not that if your machine has a T2 chip the volume will still be encrypted at rest.
-
Run the installer:
$ sh <(curl -L https://nixos.org/nix/install) --darwin-use-unencrypted-nix-store-volume --daemon
The installer is interactive but you probably want to answer affirmatively (
y
) to all of the questions. -
Restart your terminal so the proper files are sourced and test your installation:
$ nix-shell -p nix-info --run "nix-info -m"
-
Edit
/etc/zshrc
and/etc/bashrc
to remove the lines sourcingnix-daemon.sh
, which should look like this:# 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:
$ 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.
-
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. -
Edit
/etc/synthetic.conf
to remove thenix
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. -
Stop and remove the Nix daemon service:
$ 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
This stops the Nix daemon and prevents it from being started next time you boot the system.
-
Remove the files Nix added to your 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.
-
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
This will remove all the build users that no longer serve a purpose.
-
Remove the Nix Store volume:
$ 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.
Thank you ! :)