summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Sima <ben@bsima.me>2023-01-20 11:26:21 -0500
committerBen Sima <ben@bsima.me>2023-01-20 11:26:21 -0500
commit0a80f7f43e78ae6806429fda1e494c88ffc6ed02 (patch)
tree4df338d65b1fdb8fdd52c60a06de3e788e47a941
parent61daa32d4dd1ff73e44d21c5adceb3e495587286 (diff)
script to find live links to large nix closures
-rwxr-xr-xnix-audit-sizes11
1 files changed, 11 insertions, 0 deletions
diff --git a/nix-audit-sizes b/nix-audit-sizes
new file mode 100755
index 0000000..b36278c
--- /dev/null
+++ b/nix-audit-sizes
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+#
+echo "# this takes a while, be patient..."
+roots=$(find -H /nix/var/nix/gcroots/auto -type l)
+for root in $roots
+do
+ link=$(readlink $root)
+ storepath=$(realpath $link)
+ size=$(nix-store -q --requisites $storepath | sort -uf | xargs du -ch | tail -1 | sed 's/[ ]*total//g')
+ printf "%s\n\t%s\n\t%s\n\n" $size $link $storepath
+done