Files
nixpkgs/pkgs/by-name/op/opengist/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

65 lines
1.8 KiB
Bash
Executable File

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash curl coreutils jq git prefetch-npm-deps moreutils common-updater-scripts
# shellcheck shell=bash
set -eou pipefail
set -x
NIXPKGS_DIR="$(git rev-parse --show-toplevel)"
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
# Get latest release
OPENGIST_RELEASE=$(
curl --silent ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
https://api.github.com/repos/thomiceli/opengist/releases/latest
)
# Get release information
latestVersion=$(echo "$OPENGIST_RELEASE" | jq -r ".tag_name")
latestVersion="${latestVersion:1}" # remove first char 'v'
oldVersion=$(nix eval --raw -f "$NIXPKGS_DIR" opengist.version)
if [[ "$oldVersion" == "$latestVersion" ]]; then
echo "opengist is up-to-date: ${oldVersion}"
exit 0
fi
echo "Updating opengist $oldVersion -> $latestVersion"
pushd "$NIXPKGS_DIR" >/dev/null || exit 1
update-source-version opengist "${latestVersion}"
popd >/dev/null
pushd "$SCRIPT_DIR" >/dev/null || exit 1
## npm hash
rm -f package{,-lock}.json
curl -sLO "https://raw.githubusercontent.com/thomiceli/opengist/refs/tags/v$latestVersion/package-lock.json"
npmDepsHash="$(prefetch-npm-deps package-lock.json)"
sed -E 's#\bnpmDepsHash = ".*?"#npmDepsHash = "'"$npmDepsHash"'"#' --in-place package.nix
popd >/dev/null
# nix-prefetch broken due to ninja finalAttrs.src.rev
# nix-update with goModules broken for this package
setKV() {
sed -i "s|$1 = \".*\"|$1 = \"${2:-}\"|" "${SCRIPT_DIR}/package.nix"
}
setKV vendorHash "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" # The same as lib.fakeHash
set +e
VENDOR_HASH=$(nix-build --no-out-link -A opengist "$NIXPKGS_DIR" 2>&1 >/dev/null | grep "got:" | cut -d':' -f2 | sed 's| ||g')
set -e
if [ -n "${VENDOR_HASH:-}" ]; then
setKV vendorHash "${VENDOR_HASH}"
else
echo "Update failed. VENDOR_HASH is empty."
exit 1
fi