-
Notifications
You must be signed in to change notification settings - Fork 241
/
uninstall_nix_osx.sh
executable file
·84 lines (64 loc) · 2.13 KB
/
uninstall_nix_osx.sh
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
echo "Deleting all Nix installed packages"
nix-env -e '.*'
nix profile remove '.*'
echo "Running nix GC"
nix profile wipe-history
nix-collect-garbage --delete-old
nix store gc
nix store optimise
if grep -R "nix" /etc/synthetic.conf
then
sudo sed -i '' "s/nix//g" /etc/synthetic.conf
echo "Removed nix from /etc/synthetic.conf"
echo "/nix will be read-only until a reboot"
fi
echo "Unloading the daemon"
if [ -f /Library/LaunchDaemons/org.nixos.nix-daemon.plist ]; then
sudo launchctl unload /Library/LaunchDaemons/org.nixos.nix-daemon.plist
sudo rm /Library/LaunchDaemons/org.nixos.nix-daemon.plist
fi
if [ -f /etc/profile.backup-before-nix ]; then
sudo mv /etc/profile.backup-before-nix /etc/profile
fi
if [ -f /etc/bashrc.backup-before-nix ]; then
sudo mv /etc/bashrc.backup-before-nix /etc/bashrc
fi
if [ -f /etc/bash.bashrc.backup-before-nix ]; then
sudo mv /etc/bash.bashrc.backup-before-nix /etc/bash.bashrc
fi
if [ -f /etc/zshrc.backup-before-nix ]; then
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc
fi
echo "Checking if /etc/fstab has been cleaned up"
if grep -R "/nix" /etc/fstab
then
echo "You still have a /nix entry in /etc/fstab"
echo "Please remove it with 'sudo vifs'"
echo "You will have to reboot after this step"
exit 1
fi
echo "Checking if the disk was removed"
if diskutil apfs list|grep "Nix Store" -B 3
then
echo "You still have a Nix Store volumn in 'diskutil apfs list'"
echo "Please remove it with 'diskutil apfs deleteVolume <volumeDevice>'"
UUID=$(diskutil apfs list|grep "Nix Store" -B 3|head -n1|awk '{print $4}')
echo "> suggested: diskutil apfs deleteVolume $UUID"
exit 1
fi
rm -rf $HOME/.nix-*
rm -rf $HOME/.config/nixpkgs
rm -rf $HOME/.cache/nix
rm -rf $HOME/.nixpkgs
if [ -L $HOME/Applications ]; then
rm $HOME/Applications
fi
sudo rm -rf /etc/nix /nix
USERS=$(sudo dscl . list /Users | grep nixbld)
for USER in $USERS; do
sudo /usr/bin/dscl . -delete "/Users/$USER"
sudo /usr/bin/dscl . -delete /Groups/staff GroupMembership $USER;
done
sudo /usr/bin/dscl . -delete "/Groups/nixbld"
sudo rm -rf /var/root/.nix-*
sudo rm -rf /var/root/.cache/nix