Skip to content

Commit

Permalink
add handy script to find gc_roots
Browse files Browse the repository at this point in the history
  • Loading branch information
AtaraxiaSjel committed Feb 6, 2024
1 parent c75d209 commit a6744d3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions scripts/find_store_path_gc_roots.sh
@@ -0,0 +1,15 @@
#!/usr/bin/env sh

function find_store_path_gc_roots {
store_path="$(realpath $1)"
while IFS=' ' read -r gcroot derivation; do
if [[ ! $gcroot =~ ^/proc ]]; then
if nix-store -qR "$derivation" 2>/dev/null | grep -q "$store_path"; then
echo $gcroot
fi
fi
done < <(nix-store --gc --print-roots | awk '{print $1, $3}')
}


find_store_path_gc_roots "$@"

0 comments on commit a6744d3

Please sign in to comment.