nixfiles/overlay/conduit/update.sh
2022-12-20 15:28:31 +00:00

27 lines
657 B
Bash
Executable file

#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq git moreutils nix nix-prefetch
set -euo pipefail
cd "$(dirname "${BASH_SOURCE[0]}")"
json_get() {
jq -r "$1" < 'meta.json'
}
json_set() {
jq --arg x "$2" "$1 = \$x" < 'meta.json' | sponge 'meta.json'
}
old_rev=$(json_get '.rev')
new_rev=$(curl -L "https://gitlab.com/api/v4/projects/famedly%2Fconduit/repository/commits" 2>/dev/null | jq ".[0].id" -r)
if [ "$new_rev" = "$old_rev" ]; then
echo "conduit is up-to-date."
exit
fi
json_set '.rev' "$new_rev"
new_sha256=$(nix-prefetch fetchFromGitLab --owner famedly --repo conduit --rev "$new_rev")
json_set '.sha256' "$new_sha256"