### install ###

# locally trust the ci key
sudo pacman-key --recv-keys B728DB23B92CB01B && \
  sudo pacman-key --lsign-key B728DB23B92CB01B

## add the repo configuration:
sudo sh -c "curl -s https://nonfree.eu/$(pacman-mirrors -G)/ > /etc/pacman.d/mesa-nonfree.pre.repo.conf"

## include the repo configuration:
sudo sed -i '/^\[core\]/i \Include = /etc/pacman.d/mesa-nonfree.pre.repo.conf\n' /etc/pacman.conf

### uninstall ###

# remove the repo include from pacman.conf and reinstall the stock packages

PKGS="$(pacman -Sl mesa-nonfree | grep 'installed' | awk '{print $2}')" && sudo sed -i '/mesa-nonfree/d' /etc/pacman.conf && sudo pacman -Sy $(echo ${PKGS//$'\n'/ })