forked from colonelpanic/dotfiles
[NixOS] Add function to find gc roots for a store path
This commit is contained in:
parent
a8388d3c1a
commit
89f8666e2c
15
dotfiles/lib/functions/find_store_path_gc_roots
Executable file
15
dotfiles/lib/functions/find_store_path_gc_roots
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
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 "$@"
|
Loading…
Reference in New Issue
Block a user