Skip to content

Instantly share code, notes, and snippets.

@computercam
Forked from expelledboy/uninstall-nix-osx.sh
Created April 6, 2020 16:34
Show Gist options
  • Select an option

  • Save computercam/6fde76269c3715a54888bbfe1f9637f2 to your computer and use it in GitHub Desktop.

Select an option

Save computercam/6fde76269c3715a54888bbfe1f9637f2 to your computer and use it in GitHub Desktop.
Trying Nix
#!/bin/bash
rm -rf $HOME/.nix-*
rm -rf $HOME/.config/nixpkgs
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-*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment