Skip to content

Instantly share code, notes, and snippets.

@dominiwe
Created December 27, 2022 14:27
Show Gist options
  • Save dominiwe/0c8c760b53ea6bdca611dec38b40006f to your computer and use it in GitHub Desktop.
Save dominiwe/0c8c760b53ea6bdca611dec38b40006f to your computer and use it in GitHub Desktop.
Uninstall guix after installing it on top of an existing GNU/Linux system

How to uninstall guix

Date of creation: 2022-12-27

First of all, if the install script referenced here was used to install guix, ideally the output of that script as well as the script itself should have been saved somewhere. This makes it easier to see which components were installed and where and thus makes it easier for you to uninstall them.

As for me personally, I used the install script to install guix on a debian derivative distribution with systemd. This guide thus focuses on uninstalling guix from a debian derivative distribution but will probably work for your distribution as well with some slight changes.

This guide shows how to remove everything on the system from guix or the guix installation, thus we do not have to do garbage collection first.

Uninstall nscd (optional)

On this page of the manual, guix recommends to use the name service cache daemon nscd. In my case, when installing guix, I installed this with sudo apt install nscd.

If you want to stop using nscd, stop and uninstall it:

sudo systemctl stop nscd
sudo apt remove nscd

Locate, stop and remove units

Locate the systemd units installed by guix with the following command:

sudo systemctl list-units | grep 'gnu\|guix'

In my case, these were:

  • guix-daemon.service
  • gnu-store.mount

Stop these:

sudo systemctl stop guix-daemon.service
sudo systemctl stop gnu-store.mount

If you want to look at these, before deleting them, they are stored in /etc/systemd/system/.

Now, let's disable and remove them:

sudo systemctl disable guix-daemon.service
sudo systemctl disable gnu-store.mount

# delete files and directories
sudo rm /etc/systemd/system/guix-daemon.service
sudo rm -rf /etc/systemd/system/guix-daemon.service.wants
sudo rm /etc/systemd/system/gnu-store.mount
sudo rm /etc/systemd/system/multi-user.target.wants/guix-daemon.service

Remove users and groups

Guix created some users and a group. We can inspect that with the following commands:

# list users with 'guix' in the name
cat /etc/passwd | grep guix

# list groups with 'guix' in the name
cat /etc/group | grep guix

In my case, there was a group guixbuild and ten users called guixbuilder01 to guixbuilder10.

I removed these with the following bash commands:

# remove users
for i in guixbuilder{01..10}; do sudo userdel -f "$i"; done

# remove group
sudo groupdel guixbuild

Remove directories

Now we need to delete and clean up files and directories.

# delete directories (some of these may not exist on your system)
sudo rm -rf /tmp/guix.*
sudo rm -rf "$HOME/.config/guix"
sudo rm "$HOME/.guix-profile"
sudo rm -rf "$HOME/.cache/guix" "$HOME/.cache/guile"

# delete gnu store (or entire /gnu directory) and /var/guix
sudo rm -rf /gnu
sudo rm -rf /var/guix
sudo rm -rf /var/log/guix
sudo rm -rf /etc/guix

# delete guix binary symlink
sudo rm /usr/local/bin/guix

# delete info pages
sudo rm -rf /usr/local/share/info/dir*
sudo rm -rf /usr/local/share/info/guile*
sudo rm -rf /usr/local/share/info/guix*
sudo rm -rf /usr/local/share/info/images
sudo rm -rf /usr/local/share/info/gnutls-guile.info.gz

# remove completions from fish shell, if fish shell is installed
sudo rm /usr/share/fish/vendor_completions.d/guix.fish

# remove files for zsh
sudo rm -rf /usr/share/zsh/site-functions/_guix

# remove completions from bash shell
sudo rm -rf /etc/bash_completion.d/guix*

# remove environment specific files
sudo rm /etc/profile.d/zzz-guix.sh

We also need to clean/delete some files which are in the home directory of the root user. This is normally /root but it might be different on your system!

sudo rm -rf /root/.cache/guix
sudo rm -rf /root/.config/guix

Clean init files (e.g. for bash)

Restore .bashrc from before guix installation:

# first, check the differences
diff "$HOME/.bashrc.bak" "$HOME/.bashrc"

# restore if safe
mv "$HOME/.bashrc.bak" "$HOME/.bashrc"

Do the same for root:

# first, check the differences
diff "/root/.bashrc.bak" "/root/.bashrc"

# restore if safe
mv "/root/.bashrc.bak" "/root/.bashrc"

Manually clean up .profile and/or .bash_profile. In my case I manually added some lines to .profile which source some guix specific files and export some guix specific variables. I removed those manually.

Rebuild font cache (optional)

If you also followed these instructions, rebuild the font cache now that guix and the fonts installed through guix are gone:

fc-cache -rv
@JMarianoIFSTTAR
Copy link

What about the /gnu/store mounting ... ?
Thanks

@dominiwe
Copy link
Author

What about the /gnu/store mounting ... ? Thanks

Unfortunately it's been a while and I'd have to read the documentation again to give complete advice.
I think if you run both guix gc -D and systemctl disable gnu-store.mount first and then delete /gnu and /var/guix that should be enough unless your system is customized in a way I cannot anticipate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment