-
Notifications
You must be signed in to change notification settings - Fork 2
/
uninstall
executable file
·53 lines (43 loc) · 1.5 KB
/
uninstall
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env bash
set -euo pipefail
# More details available here:
# https://nix.dev/manual/nix/2.24/installation/uninstall
main() {
# Restore global rc files.
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
sudo mv /etc/bash.bashrc.backup-before-nix /etc/bash.bashrc
# Stop and remove Nix daemons and services.
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.darwin-store.plist
sudo rm /Library/LaunchDaemons/org.nixos.darwin-store.plist
# Remove nixbld group and users.
sudo dscl . -delete /Groups/nixbld
for u in $(sudo dscl . -list /Users | grep _nixbld); do sudo dscl . -delete /Users/$u; done
# Requires interaction (remove the nix volume)
sudo vifs
# Remove nix from synthetic.conf
if [ -f /etc/synthetic.conf ]; then
if [ "$(cat /etc/synthetic.conf)" = "nix" ]; then
sudo rm /etc/synthetic.conf
else
# Manual removal
sudo vi /etc/synthetic.conf
fi
fi
# Remove nix files (except for the store).
sudo rm -rf \
/etc/nix \
/var/root/.nix-profile \
/var/root/.nix-defexpr \
/var/root/.nix-channels \
~/.nix-profile \
~/.nix-defexpr \
~/.nix-channels
sudo diskutil apfs deleteVolume /nix
diskutil list
echo "If the list still contains the nix volume, run the following:"
echo " sudo diskutil apfs deleteVolume disk<X>s<Y>"
}
main "$@"