Files
nixpkgs/pkgs/msty-studio/update.sh
T
m3tam3re 20feae2098 feat: add automatic updates for vibetyper, msty-studio, zellij-ps
- vibetyper/msty-studio: unversioned AppImage URLs → HEAD/Last-Modified
  check via custom update.sh, refreshes sha256 when upstream binary changes
- zellij-ps: switch to branch-tracking (master tip via Gitea API) since
  helper-scripts repo has no tags
- all three expose passthru.updateScript so the existing CI workflow
  discovers them via is_custom_update_script
2026-07-26 12:09:22 +02:00

63 lines
2.2 KiB
Bash
Executable File

#!/usr/bin/env nix-shell
#!nix-shell --pure -i bash -p bash curl nix nix-prefetch cacert git
set -euo pipefail
# Update msty-studio AppImage hash.
#
# Upstream publishes to an unversioned URL (MstyStudio_x86_64.AppImage) — no
# version-pinned URL and no usable GitHub release. To still catch updates, we:
# 1. HEAD the URL and read the Last-Modified header
# 2. Compare to the value stored as a `# last-modified:` comment in default.nix
# 3. If changed: re-download, compute sha256, update hash + comment, commit
#
# The version attribute stays static (manual bump) — only the binary hash is
# refreshed automatically.
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
NIX_FILE="$SCRIPT_DIR/default.nix"
URL="https://next-assets.msty.studio/app/alpha/linux/MstyStudio_x86_64.AppImage"
echo "Checking $URL ..."
HEADERS=$(curl -fsSIL "$URL")
NEW_LAST_MODIFIED=$(echo "$HEADERS" | tr -d '\r' \
| awk -F': ' 'tolower($1)=="last-modified" {print $2; exit}')
if [[ -z "$NEW_LAST_MODIFIED" ]]; then
echo "ERROR: Could not read Last-Modified header from $URL" >&2
exit 1
fi
CURRENT_LAST_MODIFIED=$(awk -F': ' '/^# last-modified:/ {sub(/^# last-modified: /, ""); print; exit}' "$NIX_FILE")
echo "Current: ${CURRENT_LAST_MODIFIED:-<none>}"
echo "Latest: $NEW_LAST_MODIFIED"
if [[ "$NEW_LAST_MODIFIED" == "$CURRENT_LAST_MODIFIED" ]]; then
echo "No change, nothing to do."
exit 0
fi
echo "==> Content changed, refreshing hash..."
HASH=$(nix-prefetch-url --type sha256 "$URL" 2>/dev/null)
SRI=$(nix hash convert --hash-algo sha256 --to sri "$HASH")
echo "New sha256: $SRI"
sed -i "s|^\([[:space:]]*\)sha256 = \"[^\"]*\";|\1sha256 = \"$SRI\";|" "$NIX_FILE"
if grep -q '^# last-modified:' "$NIX_FILE"; then
sed -i "s|^# last-modified:.*|# last-modified: $NEW_LAST_MODIFIED|" "$NIX_FILE"
else
sed -i "1i # last-modified: $NEW_LAST_MODIFIED" "$NIX_FILE"
fi
echo "Updated $NIX_FILE"
NIXPKGS_ROOT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null || true)
if [[ -n "$NIXPKGS_ROOT" ]] && \
[[ -n "$(git -C "$NIXPKGS_ROOT" status --porcelain "$NIX_FILE")" ]]; then
git -C "$NIXPKGS_ROOT" add "$NIX_FILE"
git -C "$NIXPKGS_ROOT" commit -m "msty-studio: refresh AppImage ($NEW_LAST_MODIFIED)"
echo "==> Committed"
fi