diff options
Diffstat (limited to '')
| -rwxr-xr-x | scripts/why-depends | 57 |
1 files changed, 48 insertions, 9 deletions
diff --git a/scripts/why-depends b/scripts/why-depends index 01471ce2..ae1ac6f7 100755 --- a/scripts/why-depends +++ b/scripts/why-depends @@ -1,17 +1,56 @@ #! /usr/bin/env sh -package="$1" -version="$2" -shift 2 +main() { + use_running="$1" + host="$2" + package="$3" + + if [ "$use_running" = "true" ]; then + base="/run/current-system" + else + base=".#nixosConfigurations.$host.config.system.build.toplevel" + fi + + fd "[a-zA-Z0-9]{32}-$package" /nix/store --type directory --threads 1 --exec nix --option warn-dirty false why-depends "$base" +} + +running=false +host="$(hostname)" +packages="" +direct_packages="" + +while [ "$#" -ne 0 ]; do + case "$1" in + "--running") + running=true + ;; + "--host") + shift 1 + host="$1" + ;; + "--direct") + shift 1 + direct_packages="$direct_packages $1" + ;; + *) + # Treat everything else as a package to check + packages="$packages $1" + ;; + esac -if [ "$1" = "--running" ]; then shift 1 - base="/run/current-system" -else - host="$(hostname)" - base=".#nixosConfigurations.$host.config.system.build.toplevel" +done + +if [ -n "$packages" ]; then + for package in $packages; do + main "$running" "$host" "$package-" + done fi -fd "$package-$version$" /nix/store --type directory --threads 1 --exec nix why-depends "$@" "$base" +if [ -n "$direct_packages" ]; then + for package in $direct_packages; do + main "$running" "$host" "$package-[0-9]" + done +fi # vim: ft=sh |
