-
-
Save dfrankland/a982fd45b50a2a56f8e3d9a2ea0bf03c to your computer and use it in GitHub Desktop.
Trying Nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# !!WARNING!! | |
# This will DELETE all efforts you have put into configuring nix | |
# Have a look through everything that gets deleted / copied over | |
nix-env -e '.*' | |
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 | |
# Nix wasnt installed using `--daemon` | |
[ ! -f /Library/LaunchDaemons/org.nixos.nix-daemon.plist ] && exit 0 | |
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/zshrc.backup-before-nix ]; then | |
sudo mv /etc/zshrc.backup-before-nix /etc/zshrc | |
fi | |
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 | |
# useful for finding hanging links | |
# $ find . -type l -maxdepth 5 ! -exec test -e {} \; -print 2>/dev/null | xargs -I {} sh -c 'file -b {} | grep nix && echo {}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment