#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix

# script to reclaim some hard drive space
# some of this is documented here:
# - <https://nixos.wiki/wiki/Storage_optimization>

set -xeu

# scan the store and hard-link identical files
# nix-store --optimise

# TODO: `nix-store --gc`?
nix-collect-garbage --delete-older-than 30d

if [ "$(id -u)" -ne 0 ]; then
  echo "now re-run as root to free old system-level generations"
fi
