sane-scripts: sane-reclaim-disk-space: use nix-store --optimise
This commit is contained in:
parent
12f3fc333d
commit
396d094520
|
@ -1,23 +1,52 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# script to reclaim some hard drive space
|
# script to reclaim some hard drive space
|
||||||
|
# some of this is documented here:
|
||||||
|
# - <https://nixos.wiki/wiki/Storage_optimization>
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
options=$(getopt -l "fast" -o "f" -- "$@")
|
options=$(getopt -l "gc,rmlint,all" -- "" "$@")
|
||||||
do_rmlint=true
|
eval "set -- ${options}"
|
||||||
for arg in $options; do
|
do_rmlint=false
|
||||||
case $arg in
|
do_gc=false
|
||||||
-f|--fast)
|
while true; do
|
||||||
do_rmlint=false
|
case "$1" in
|
||||||
;;
|
(--all)
|
||||||
--)
|
shift
|
||||||
;;
|
do_gc=true
|
||||||
|
do_rmlint=true
|
||||||
|
;;
|
||||||
|
(--gc)
|
||||||
|
shift
|
||||||
|
do_gc=true
|
||||||
|
;;
|
||||||
|
(--rmlint)
|
||||||
|
shift
|
||||||
|
do_rmlint=true
|
||||||
|
;;
|
||||||
|
(--)
|
||||||
|
shift
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
(*)
|
||||||
|
echo "invalid arguments"
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
# always claim nix garbage
|
# scan the store and hard-link identical files
|
||||||
sudo nix-collect-garbage
|
# nix-store --optimise
|
||||||
|
|
||||||
|
if [ $do_gc = true ]
|
||||||
|
then
|
||||||
|
# TODO: do we need `sudo` here?
|
||||||
|
# TODO: `nix-store --gc`?
|
||||||
|
sudo nix-collect-garbage
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $do_rmlint = true ]
|
if [ $do_rmlint = true ]
|
||||||
then
|
then
|
||||||
|
|
Loading…
Reference in New Issue
Block a user