fix nix-build-and-cache

Now it actually caches everything.

Signed-off-by: strawberry <strawberry@puppygock.gay>
This commit is contained in:
Charles Hall 2024-05-06 00:08:20 -04:00 committed by June
parent d657fa32e9
commit 8c21388f01

View file

@ -13,7 +13,11 @@ just() {
nix build -L "$@" nix build -L "$@"
fi fi
if [ ! -z "$ATTIC_TOKEN" ]; then if [ -z "$ATTIC_TOKEN" ]; then
echo "\$ATTIC_TOKEN is unset, skipping uploading to the binary cache"
return
fi
# historical "conduit" store for compatibility purposes, same as conduwuit # historical "conduit" store for compatibility purposes, same as conduwuit
nix run --inputs-from "$toplevel" attic -- \ nix run --inputs-from "$toplevel" attic -- \
login \ login \
@ -21,15 +25,25 @@ just() {
"${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduit}" \ "${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduit}" \
"$ATTIC_TOKEN" "$ATTIC_TOKEN"
readarray -t outputs < <(nix path-info "$@") # 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=()
for derivation in "${derivations[@]}"; do
cache+=(
"$(nix-store --query --requisites --include-outputs "$derivation")"
)
done
# Push the target installable and its build dependencies # Upload them to Attic (conduit store)
nix run --inputs-from "$toplevel" attic -- \ #
push \ # Use `xargs` and a here-string because something would probably explode if
conduit \ # several thousand arguments got passed to a command at once. Hopefully no
"${outputs[@]}" \ # store paths include a newline in them.
"${derivations[@]}" (
IFS=$'\n'
nix shell --inputs-from "$toplevel" attic -c xargs \
attic push conduit <<< "${cache[*]}"
)
# main "conduwuit" store # main "conduwuit" store
nix run --inputs-from "$toplevel" attic -- \ nix run --inputs-from "$toplevel" attic -- \
@ -38,16 +52,16 @@ just() {
"${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduwuit}" \ "${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduwuit}" \
"$ATTIC_TOKEN" "$ATTIC_TOKEN"
# Push the target installable and its build dependencies # Upload them to Attic (conduwuit store)
nix run --inputs-from "$toplevel" attic -- \ #
push \ # Use `xargs` and a here-string because something would probably explode if
conduwuit \ # several thousand arguments got passed to a command at once. Hopefully no
"${outputs[@]}" \ # store paths include a newline in them.
"${derivations[@]}" (
else IFS=$'\n'
echo "\$ATTIC_TOKEN is unset, skipping uploading to the binary cache" nix shell --inputs-from "$toplevel" attic -c xargs \
fi attic push conduwuit <<< "${cache[*]}"
)
} }
# Build and cache things needed for CI # Build and cache things needed for CI
@ -56,7 +70,7 @@ ci() {
--inputs-from "$toplevel" --inputs-from "$toplevel"
# Keep sorted # Keep sorted
"$toplevel#devShells.x86_64-linux.default.inputDerivation" "$toplevel#devShells.x86_64-linux.default"
attic#default attic#default
nixpkgs#direnv nixpkgs#direnv
nixpkgs#jq nixpkgs#jq