#!/usr/bin/env bash
set -Eeuo pipefail

yellow "Cleaning up the NixOS store"

profiles=(per-user/root/channels per-user/andreh/profile per-user/andreh/channels system)

for p in "${profiles[@]}"; do
    sudo nix-env --delete-generations old -p "/nix/var/nix/profiles/$p"
done

# Current profile, change when installing with =nix-env -iA nixpkgs.bsdgames=
nix-env --delete-generations old

nix-store --gc
nix-collect-garbage -d
