Files
nixpkgs/pkgs/by-name/kr/krunker/update.sh
Dark Steveneq 646b892680
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s
push sheeet
2025-10-09 14:15:47 +02:00

59 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/env nix-shell
#! nix-shell --pure -i bash -p bash cacert common-updater-scripts curl yq
# shellcheck shell=bash
set -euo pipefail
root=$(readlink -f "$0" | xargs dirname)
script_name="krunker-update"
updater_url="client2.krunker.io"
log() {
echo "$script_name: $*"
}
panic() {
log "$*"
exit 1
}
update() {
platform="${1:-}"
if [ -z "$platform" ]; then
panic "error: a platform must be supplied to \`update()\`!"
fi
nixfile="$root"/"$platform".nix
if [ ! -f "$nixfile" ]; then
panic "error: $platform is not supported!"
fi
electron_suffix=""
system="x86_64-linux"
if [ "$platform" == "darwin" ]; then
electron_suffix="-mac"
system="aarch64-darwin"
elif [ "$platform" == "linux" ]; then
electron_suffix="-linux"
fi
url="https://$updater_url/latest${electron_suffix}.yml"
log "fetching update information from from $url"
response="$(curl -sSL "$url")"
version="$(yq --raw-output '.version' <<<"$response")"
sha512="$(yq \
--raw-output \
'.files | map(select(.url | contains("dmg") or contains("AppImage"))) | first | .sha512' \
<<<"$response")"
update-source-version krunker "$version" sha512-"$sha512" --file="$nixfile" --system="$system"
}
supported_platforms=(
"darwin"
"linux"
)
for platform in "${supported_platforms[@]}"; do
update "$platform"
done