mirror of
https://github.com/girlbossceo/conduwuit.git
synced 2024-11-27 02:45:27 +00:00
30e3e45f9f
Signed-off-by: strawberry <strawberry@puppygock.gay>
111 lines
3.1 KiB
Bash
Executable file
111 lines
3.1 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -eo pipefail
|
|
|
|
toplevel="$(git rev-parse --show-toplevel)"
|
|
|
|
# Build just the single installable and forward any other arguments too
|
|
just() {
|
|
# uses nix-output-monitor (nom) if available
|
|
if command -v nom &> /dev/null; then
|
|
nom build "$@"
|
|
else
|
|
nix build -L "$@"
|
|
fi
|
|
|
|
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
|
|
nix run --inputs-from "$toplevel" attic -- \
|
|
login \
|
|
conduit \
|
|
"${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduit}" \
|
|
"$ATTIC_TOKEN"
|
|
|
|
# Find all output paths of the installables and their build dependencies
|
|
#readarray -t derivations < <(nix path-info --derivation "$@")
|
|
derivations=()
|
|
while IFS=$'\n' read derivation; do
|
|
derivations+=("$derivation")
|
|
done < <(nix path-info --derivation "$@")
|
|
|
|
cache=()
|
|
for derivation in "${derivations[@]}"; do
|
|
cache+=(
|
|
"$(nix-store --query --requisites --include-outputs "$derivation")"
|
|
)
|
|
done
|
|
|
|
withattic() {
|
|
nix shell --inputs-from "$toplevel" attic --command xargs attic push "$@" <<< "${cache[*]}"
|
|
}
|
|
# Upload them to Attic (conduit store)
|
|
#
|
|
# Use `xargs` and a here-string because something would probably explode if
|
|
# several thousand arguments got passed to a command at once. Hopefully no
|
|
# store paths include a newline in them.
|
|
(
|
|
IFS=$'\n'
|
|
withattic conduit || withattic conduit || withattic conduit || true
|
|
)
|
|
|
|
# main "conduwuit" store
|
|
nix run --inputs-from "$toplevel" attic -- \
|
|
login \
|
|
conduwuit \
|
|
"${ATTIC_ENDPOINT:-https://attic.kennel.juneis.dog/conduwuit}" \
|
|
"$ATTIC_TOKEN"
|
|
|
|
# Upload them to Attic (conduwuit store) and Cachix
|
|
#
|
|
# Use `xargs` and a here-string because something would probably explode if
|
|
# several thousand arguments got passed to a command at once. Hopefully no
|
|
# store paths include a newline in them.
|
|
(
|
|
IFS=$'\n'
|
|
withattic conduwuit || withattic conduwuit || withattic conduwuit || true
|
|
|
|
# push to cachix if available
|
|
if [ "$CACHIX_AUTH_TOKEN" ]; then
|
|
nix shell --inputs-from "$toplevel" cachix -c xargs \
|
|
cachix push conduwuit <<< "${cache[*]}"
|
|
fi
|
|
)
|
|
}
|
|
|
|
# Build and cache things needed for CI
|
|
ci() {
|
|
cache=(
|
|
--inputs-from "$toplevel"
|
|
|
|
# Keep sorted
|
|
#"$toplevel#devShells.x86_64-linux.default"
|
|
#"$toplevel#devShells.x86_64-linux.all-features"
|
|
attic#default
|
|
cachix#default
|
|
nixpkgs#direnv
|
|
nixpkgs#jq
|
|
nixpkgs#nix-direnv
|
|
)
|
|
|
|
just "${cache[@]}"
|
|
}
|
|
|
|
# Build and cache *all* the package outputs from the flake.nix
|
|
packages() {
|
|
declare -a cache="($(
|
|
nix flake show --json 2> /dev/null |
|
|
nix run --inputs-from "$toplevel" nixpkgs#jq -- \
|
|
-r \
|
|
'.packages."x86_64-linux" | keys | map("'"$toplevel"'#" + .) | @sh'
|
|
))"
|
|
|
|
just "${cache[@]}"
|
|
}
|
|
|
|
|
|
eval "$@"
|