sunshine: fix updater script

The script broke when invoked from the package directory: nix-update
looked for a default.nix in the cwd. Move to the nixpkgs root before
calling it.

`--generate-lockfile` and the npmDepsHash refresh are mutually exclusive
in a single nix-update pass, so the ui subpackage hash was never
updated.
Split the ui update into two passes.

Also restore the early-exit when UPDATE_NIX_OLD_VERSION matches, quote
$version, and add the shellcheck shell directive.

Assisted-by: Claude Code 4.7
(cherry picked from commit 0085f4f7a8)
This commit is contained in:
Qubasa 2026-05-19 13:05:43 +02:00 committed by github-actions[bot]
commit 4c14f3f2ab

View file

@ -1,13 +1,20 @@
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p gnugrep curl jq nix-update
# shellcheck shell=bash
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")/../../../.."
version=$(curl ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} --silent --location https://api.github.com/repos/LizardByte/Sunshine/releases/latest | jq --raw-output .tag_name | grep -oP "^v\K.*")
if [[ "$UPDATE_NIX_OLD_VERSION" == "$version" ]]; then
if [[ "${UPDATE_NIX_OLD_VERSION:-}" == "$version" ]]; then
echo "Already up to date!"
exit 0
fi
nix-update sunshine --version $version --generate-lockfile --subpackage ui
nix-update sunshine --version "$version"
# `--generate-lockfile` only regenerates package-lock.json; it skips the npmDepsHash
# refresh (see nix-update's dependency_hashes.py). Run a second pass to update the hash.
nix-update sunshine --version=skip --generate-lockfile --subpackage ui
nix-update sunshine --version=skip --subpackage ui