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