sane-reclaim-disk-space: remove rmlint
i wasn't using it, and now we can emulate less :)
This commit is contained in:
@@ -1115,11 +1115,11 @@ in {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
rmlint = prev.rmlint.override {
|
# rmlint = prev.rmlint.override {
|
||||||
# fixes "Checking whether the C compiler works... no"
|
# # fixes "Checking whether the C compiler works... no"
|
||||||
# rmlint is scons; it reads the CC environment variable, though, so *may* be cross compilable
|
# # rmlint is scons; it reads the CC environment variable, though, so *may* be cross compilable
|
||||||
inherit (emulated) stdenv;
|
# inherit (emulated) stdenv;
|
||||||
};
|
# };
|
||||||
# 2023/07/30: upstreaming is ?; implemented on servo cross-staging-2023-07-30 branch
|
# 2023/07/30: upstreaming is ?; implemented on servo cross-staging-2023-07-30 branch
|
||||||
rpm = prev.rpm.overrideAttrs (upstream: {
|
rpm = prev.rpm.overrideAttrs (upstream: {
|
||||||
# fixes "python too old". might also be specifiable as a configure flag?
|
# fixes "python too old". might also be specifiable as a configure flag?
|
||||||
|
@@ -144,7 +144,7 @@ let
|
|||||||
reclaim-disk-space = static-nix-shell.mkBash {
|
reclaim-disk-space = static-nix-shell.mkBash {
|
||||||
pname = "sane-reclaim-disk-space";
|
pname = "sane-reclaim-disk-space";
|
||||||
src = ./src;
|
src = ./src;
|
||||||
pkgs = [ "nix" "rmlint" "util-linux" ];
|
pkgs = [ "nix" ];
|
||||||
};
|
};
|
||||||
secrets-dump = static-nix-shell.mkBash {
|
secrets-dump = static-nix-shell.mkBash {
|
||||||
pname = "sane-secrets-dump";
|
pname = "sane-secrets-dump";
|
||||||
|
@@ -1,74 +1,20 @@
|
|||||||
#!/usr/bin/env nix-shell
|
#!/usr/bin/env nix-shell
|
||||||
#!nix-shell -i bash -p nix -p rmlint -p util-linux
|
#!nix-shell -i bash -p nix
|
||||||
# script to reclaim some hard drive space
|
# script to reclaim some hard drive space
|
||||||
# some of this is documented here:
|
# some of this is documented here:
|
||||||
# - <https://nixos.wiki/wiki/Storage_optimization>
|
# - <https://nixos.wiki/wiki/Storage_optimization>
|
||||||
set -e
|
|
||||||
|
|
||||||
options=$(getopt -l "gc,rmlint,all" -- "" "$@")
|
set -xeu
|
||||||
eval "set -- ${options}"
|
|
||||||
do_rmlint=false
|
|
||||||
do_gc=false
|
|
||||||
while true; do
|
|
||||||
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
|
|
||||||
done
|
|
||||||
|
|
||||||
set -x
|
|
||||||
|
|
||||||
# scan the store and hard-link identical files
|
# scan the store and hard-link identical files
|
||||||
# nix-store --optimise
|
# nix-store --optimise
|
||||||
|
|
||||||
if [ $do_gc = true ]
|
# TODO: do we need `sudo` here?
|
||||||
then
|
# TODO: `nix-store --gc`?
|
||||||
# TODO: do we need `sudo` here?
|
sudo nix-collect-garbage --delete-older-than 30d
|
||||||
# TODO: `nix-store --gc`?
|
|
||||||
sudo nix-collect-garbage --delete-older-than 30d
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $do_rmlint = true ]
|
# TODO: could use dduper: https://github.com/Lakshmipathi/dduper
|
||||||
then
|
# like rmlint, but better perf for btrfs (checksum tests)
|
||||||
# identify duplicate files in the nix store
|
|
||||||
rmlint --types="duplicates" --config=sh:handler=clone --output=sh:/tmp/rmlint.sh --output=json:/dev/null --progress /nix/store
|
|
||||||
# link the dupes together (uses ioctl_fideduperange)
|
|
||||||
# see: https://btrfs.wiki.kernel.org/index.php/Deduplication
|
|
||||||
# see: https://rmlint.readthedocs.io/en/latest/tutorial.html
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ $do_rmlint = true ]
|
|
||||||
then
|
|
||||||
sudo mount -o remount,rw /nix/store
|
|
||||||
# XXX: does rmlint really need to be invoked as root?
|
|
||||||
sudo /tmp/rmlint.sh -d || true # on failure, we still want to remount ro
|
|
||||||
# XXX this doesn't work: 'mount point is busy.'
|
|
||||||
sudo mount -o remount,ro /nix/store
|
|
||||||
fi
|
|
||||||
|
|
||||||
# TODO: instead of using rmlint, could use dduper: https://github.com/Lakshmipathi/dduper
|
|
||||||
# better perf for btrfs (checksum tests)
|
|
||||||
# likely also better compression, on account of being block-based instead of whole-file based.
|
# likely also better compression, on account of being block-based instead of whole-file based.
|
||||||
# however, not clearly actively maintained; uses custom btrfs-progs patch; riskier
|
# however, not clearly actively maintained; uses custom btrfs-progs patch; riskier
|
||||||
# might not currently build on nix: https://github.com/NixOS/nixpkgs/issues/175730
|
# might not currently build on nix: https://github.com/NixOS/nixpkgs/issues/175730
|
||||||
|
Reference in New Issue
Block a user