diff options
author | Otto Sabart <seberm@seberm.com> | 2023-03-28 21:00:00 +0200 |
---|---|---|
committer | Otto Sabart <seberm@seberm.com> | 2023-03-28 21:00:00 +0200 |
commit | 511d699e4e4a29756cdd481ca92a6e3ae8e4aec2 (patch) | |
tree | af5876448ab8e8c542d8976f5b0f606fdc0f0685 /pkgs/applications/blockchains | |
parent | 2345d940988cbf48ba3909c7ae5f299f1a7556b7 (diff) |
teos: add update script
Diffstat (limited to 'pkgs/applications/blockchains')
-rw-r--r-- | pkgs/applications/blockchains/teos/default.nix | 5 | ||||
-rwxr-xr-x | pkgs/applications/blockchains/teos/update.sh | 31 |
2 files changed, 36 insertions, 0 deletions
diff --git a/pkgs/applications/blockchains/teos/default.nix b/pkgs/applications/blockchains/teos/default.nix index a8ce5ca242075..fbd8c08575d5d 100644 --- a/pkgs/applications/blockchains/teos/default.nix +++ b/pkgs/applications/blockchains/teos/default.nix @@ -24,6 +24,7 @@ let license = licenses.mit; maintainers = with maintainers; [ seberm ]; }; + updateScript = ./update.sh; in { teos = rustPlatform.buildRustPackage { @@ -43,6 +44,8 @@ in darwin.apple_sdk.frameworks.Security ]; + passthru.updateScript = updateScript; + __darwinAllowLocalNetworking = true; meta = meta // { @@ -70,6 +73,8 @@ in darwin.apple_sdk.frameworks.SystemConfiguration ]; + passthru.updateScript = updateScript; + __darwinAllowLocalNetworking = true; meta = meta // { diff --git a/pkgs/applications/blockchains/teos/update.sh b/pkgs/applications/blockchains/teos/update.sh new file mode 100755 index 0000000000000..b7e344cda8447 --- /dev/null +++ b/pkgs/applications/blockchains/teos/update.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p coreutils curl jq git gnupg common-updater-scripts +set -euo pipefail + +# Fetch latest release, update derivation +scriptDir=$(cd "${BASH_SOURCE[0]%/*}" && pwd) +nixpkgs=$(realpath "$scriptDir"/../../../..) + +oldVersion=$(nix-instantiate --eval -E "(import \"$nixpkgs\" { config = {}; overlays = []; }).teos.version" | tr -d '"') +version=$(curl -s --show-error "https://api.github.com/repos/talaia-labs/rust-teos/releases/latest" | jq -r '.tag_name' | tail -c +2) + +if [[ $version == $oldVersion ]]; then + echo "Already at latest version $version" + exit 0 +fi +echo "New version: $version" + +tmpdir=$(mktemp -d /tmp/teos.XXX) +repo="${tmpdir}/repo" +trap 'rm -rf $tmpdir' EXIT + +git clone --depth 1 --branch "v${version}" -c advice.detachedHead=false 'https://github.com/talaia-labs/rust-teos' "$repo" +git -C "$repo" checkout "tags/v${version}" + +rm -rf "${repo}/.git" +hashcheck=$(nix hash path "$repo") + +(cd "$nixpkgs" && update-source-version teos "$version" "$hashcheck") +sed -i 's|cargoHash = .*|cargoHash = "sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=";|' "${scriptDir}/default.nix" +echo +echo "rust-teos: $oldVersion -> $version" |