Skip to content

Instantly share code, notes, and snippets.

@mbrock
Created November 2, 2017 09:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mbrock/c2fd0c56f22e0e69ab18d41e697964b8 to your computer and use it in GitHub Desktop.
Save mbrock/c2fd0c56f22e0e69ab18d41e697964b8 to your computer and use it in GitHub Desktop.
#! /usr/bin/env nix-shell
#! nix-shell -i bash -p nix-prefetch-scripts curl jshon jq
set -e
json="{}"
add() { json=$(jshon "$@" <<<"$json"); }
rm -rf overlay/upstream
mkdir -p overlay/upstream
GET() {
curl -s -H "Authorization: token ${GITHUB_TOKEN?Need OAuth token}" "$@"
}
package() {
echo -n bumping "$1 "
pkg="$1"
name=$(basename "$pkg")
tag=$(GET https://api.github.com/repos/"$pkg"/tags | jshon -e 0)
version=$(jshon -e name -u <<<"$tag")
hash=$(jshon -e commit -e sha -u <<<"$tag")
echo -n "$version"
sha256=$(
nix-prefetch-url \
--unpack \
https://github.com/"$pkg"/archive/"$version".tar.gz 2>/dev/null)
add -n {} \
-s "${version#v}" -i version \
-n {} \
-s "$hash" -i rev \
-s "$sha256" -i sha256 \
-s "$(dirname "$pkg")" -i owner \
-s "$name" -i repo \
-i src \
-i "$name"
tree=$(GET https://api.github.com/repos/"$pkg"/git/trees/"$hash")
nix=$(jq -r <<<"$tree" '.tree | .[] | select(.path == "default.nix") | .url')
GET "$nix" | jshon -e content -u | base64 -d > overlay/upstream/$name.nix
echo
}
# These are the GitHub packages I have in my overlay
package dapphub/dapp
package dapphub/hevm
package dapphub/seth
package lessrest/restless-git
package mbrock/jays
echo "$json" | jq . > overlay/versions.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment