nix-files/pkgs/additional/sane-scripts/src/sane-reclaim-disk-space
Colin c50a4d1d71 static-nix-shell: fix mkBash scripts to actually be invokable from the CLI
they need the `bash` package! how did this work before?
2024-06-15 07:42:04 +00:00

25 lines
666 B
Plaintext
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash -p nix
# script to reclaim some hard drive space
# some of this is documented here:
# - <https://nixos.wiki/wiki/Storage_optimization>
if [ "$(id -u)" -ne 0 ]; then
echo 'must be run as root!'
fi
set -xeu
# scan the store and hard-link identical files
# nix-store --optimise
nix-collect-garbage --delete-older-than 30d
set +x
echo 'to free more space (e.g. boot space), manually manage the profiles'
echo '- nix-env --profile /nix/var/nix/profiles/system --list-generations'
echo '- nix-env --profile /nix/var/nix/profiles/system --delete-generations {first..last}'
echo '- sudo sane-reclaim-boot-space`