use more readarray

The first part replaces a loop which is probably a performance
improvement, and the second part addresses a shellcheck complaint about
not declaring and assigning separately.
This commit is contained in:
Charles Hall 2025-07-30 09:26:34 -07:00
parent 27667911ed
commit cf4f2fe51b

View file

@ -25,12 +25,11 @@ just() {
# Find all output paths of the installables and their build dependencies
readarray -t derivations < <(nix path-info --derivation "$@")
cache=()
for derivation in "${derivations[@]}"; do
cache+=(
"$(nix-store --query --requisites --include-outputs "$derivation")"
)
done
readarray -t cache < <(
xargs \
nix-store --query --requisites --include-outputs \
<<< "${derivations[*]}"
)
# Upload them to Attic
#
@ -62,12 +61,12 @@ ci() {
# Build and cache all the package outputs
packages() {
declare -a cache="($(
readarray -t cache < <(
nix flake show --json 2> /dev/null |
nix run --inputs-from "$toplevel" nixpkgs#jq -- \
-r \
'.packages."x86_64-linux" | keys | map("'"$toplevel"'#" + .) | @sh'
))"
'.packages."x86_64-linux" | keys | map("'"$toplevel"'#" + .) | .[]'
)
just "${cache[@]}"
}