nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 39 lines 1.5 kB view raw
1#!/usr/bin/env nix-shell 2#!nix-shell -i bash -p curl common-updater-scripts coreutils jq prefetch-yarn-deps git 3 4set -euo pipefail 5set -x 6 7cd "$(git rev-parse --show-toplevel)" 8 9TMPDIR=$(mktemp -d) 10 11echo "Getting versions..." 12latestVersion="$(curl -sL "https://api.github.com/repos/the-draupnir-project/Draupnir/releases?per_page=1" | jq -r '.[0].tag_name | ltrimstr("v")')" 13echo " --> Latest version: ${latestVersion}" 14currentVersion=$(nix-instantiate --eval -E "with import ./. {}; draupnir.version or (lib.getVersion draupnir)" | tr -d '"') 15echo " --> Current version: ${currentVersion}" 16if [[ "$currentVersion" == "$latestVersion" ]]; then 17 echo "Draupnir is up-to-date: $currentVersion" 18 exit 0 19else 20 echo "We are out of date..." 21fi 22 23curl https://raw.githubusercontent.com/the-draupnir-project/Draupnir/v$latestVersion/package.json -o pkgs/by-name/dr/draupnir/package.json 24 25update-source-version draupnir "$latestVersion" 26 27# Update yarn offline cache hash 28cd $TMPDIR 29 30curl https://raw.githubusercontent.com/the-draupnir-project/Draupnir/v$latestVersion/yarn.lock -o yarn.lock 31TMP_PREFETCH_HASH=`prefetch-yarn-deps yarn.lock` 32NEW_YARN_OFFLINE_HASH=`nix --extra-experimental-features nix-command hash to-sri --type sha256 $TMP_PREFETCH_HASH` 33 34cd - 35echo "New yarn offline hash: $NEW_YARN_OFFLINE_HASH" 36 37TMPFILE=$(mktemp) 38jq '.yarn_offline_cache_hash = "'$NEW_YARN_OFFLINE_HASH'"' pkgs/by-name/dr/draupnir/hashes.json > $TMPFILE 39mv -- "$TMPFILE" pkgs/by-name/dr/draupnir/hashes.json