From 206dd8447797ff37efa302e6f613b48badc91725 Mon Sep 17 00:00:00 2001 From: Colin Date: Mon, 31 Jul 2023 03:10:38 +0000 Subject: [PATCH] sane-reclaim-disk-space: remove rmlint i wasn't using it, and now we can emulate less :) --- overlays/cross.nix | 10 +-- pkgs/additional/sane-scripts/default.nix | 2 +- .../sane-scripts/src/sane-reclaim-disk-space | 68 ++----------------- 3 files changed, 13 insertions(+), 67 deletions(-) diff --git a/overlays/cross.nix b/overlays/cross.nix index 711b3b247..bf6505d98 100644 --- a/overlays/cross.nix +++ b/overlays/cross.nix @@ -1115,11 +1115,11 @@ in { }); }); - rmlint = prev.rmlint.override { - # fixes "Checking whether the C compiler works... no" - # rmlint is scons; it reads the CC environment variable, though, so *may* be cross compilable - inherit (emulated) stdenv; - }; + # rmlint = prev.rmlint.override { + # # fixes "Checking whether the C compiler works... no" + # # rmlint is scons; it reads the CC environment variable, though, so *may* be cross compilable + # inherit (emulated) stdenv; + # }; # 2023/07/30: upstreaming is ?; implemented on servo cross-staging-2023-07-30 branch rpm = prev.rpm.overrideAttrs (upstream: { # fixes "python too old". might also be specifiable as a configure flag? diff --git a/pkgs/additional/sane-scripts/default.nix b/pkgs/additional/sane-scripts/default.nix index 0c9af92d3..e34f59be5 100644 --- a/pkgs/additional/sane-scripts/default.nix +++ b/pkgs/additional/sane-scripts/default.nix @@ -144,7 +144,7 @@ let reclaim-disk-space = static-nix-shell.mkBash { pname = "sane-reclaim-disk-space"; src = ./src; - pkgs = [ "nix" "rmlint" "util-linux" ]; + pkgs = [ "nix" ]; }; secrets-dump = static-nix-shell.mkBash { pname = "sane-secrets-dump"; diff --git a/pkgs/additional/sane-scripts/src/sane-reclaim-disk-space b/pkgs/additional/sane-scripts/src/sane-reclaim-disk-space index 108b5f950..8e1510138 100755 --- a/pkgs/additional/sane-scripts/src/sane-reclaim-disk-space +++ b/pkgs/additional/sane-scripts/src/sane-reclaim-disk-space @@ -1,74 +1,20 @@ #!/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 # some of this is documented here: # - -set -e -options=$(getopt -l "gc,rmlint,all" -- "" "$@") -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 +set -xeu # scan the store and hard-link identical files # nix-store --optimise -if [ $do_gc = true ] -then - # TODO: do we need `sudo` here? - # TODO: `nix-store --gc`? - sudo nix-collect-garbage --delete-older-than 30d -fi +# TODO: do we need `sudo` here? +# TODO: `nix-store --gc`? +sudo nix-collect-garbage --delete-older-than 30d -if [ $do_rmlint = true ] -then - # 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) +# TODO: could use dduper: https://github.com/Lakshmipathi/dduper +# like rmlint, but better perf for btrfs (checksum tests) # 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 # might not currently build on nix: https://github.com/NixOS/nixpkgs/issues/175730