#!/usr/bin/env bash

disk_space() {
  u | awk '{print $5" "$6}'
}

before=$(disk_space)

gc-nix.sh

yellow "Cleaning up Guix store"

guix gc


yellow "Cleaning up up the Trash and /tmp folders"

sudo rm -rf ~/.local/share/Trash/files/*
# https://askubuntu.com/a/609396
sudo find /tmp -type f -atime +10 -delete


yellow "Erasing docker images"

echo y | docker system prune -a
docker rmi "$(docker images -a -q)"
docker rm "$(docker ps -a -f status=exited -q)"

docker stop "$(docker ps -a -q)"
docker rm "$(docker ps -a -q)"

echo y | docker volume prune
echo y | docker container prune

gc-mail.sh

after=$(disk_space)

green "Done."
green "Disk space before and after:"
blue "  before: ${before}"
blue "  after:  ${after}"
