From d7522e6c9bc69f05aa626b2dd695ba10742c0345 Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Sat, 2 Dec 2023 12:12:55 +0100 Subject: [PATCH] heroku: add updateScript --- pkgs/development/tools/heroku/default.nix | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/pkgs/development/tools/heroku/default.nix b/pkgs/development/tools/heroku/default.nix index 090e5fa8fd7d..0df1b97b1520 100644 --- a/pkgs/development/tools/heroku/default.nix +++ b/pkgs/development/tools/heroku/default.nix @@ -1,19 +1,12 @@ -{ stdenv, lib, fetchzip, makeWrapper, nodejs }: +{ stdenv, lib, fetchzip, makeWrapper, nodejs, writeScript }: -let - # version and commit pairs can be found in the URLs at - # https://cli-assets.heroku.com/versions/heroku-linux-x64-tar-xz.json - version = "8.7.1"; - commit = "3f5e369"; - hash = "sha256-3pCutQBS8N1Yw4JKTvU046UrOxBi0wLRQywxwezAEeU"; -in stdenv.mkDerivation { pname = "heroku"; - inherit version; + version = "8.7.1"; src = fetchzip { - url = "https://cli-assets.heroku.com/versions/${version}/${commit}/heroku-v${version}-${commit}-linux-x64.tar.xz"; - inherit hash; + url = "https://cli-assets.heroku.com/versions/8.7.1/3f5e369/heroku-v8.7.1-3f5e369-linux-x64.tar.xz"; + hash = "sha256-3pCutQBS8N1Yw4JKTvU046UrOxBi0wLRQywxwezAEeU="; }; nativeBuildInputs = [ makeWrapper ]; @@ -29,6 +22,19 @@ stdenv.mkDerivation { --set HEROKU_DISABLE_AUTOUPDATE 1 ''; + passthru.updateScript = writeScript "update-heroku" '' + #!/usr/bin/env nix-shell + #!nix-shell -I nixpkgs=./. -i bash -p nix-prefetch curl jq common-updater-scripts + resp="$( + curl -L "https://cli-assets.heroku.com/versions/heroku-linux-x64-tar-xz.json" \ + | jq '[to_entries[] | { version: .key, url: .value } | select(.version|contains("-")|not)] | sort_by(.version|split(".")|map(tonumber)) | .[-1]' + )" + url="$(jq <<<"$resp" .url --raw-output)" + version="$(jq <<<"$resp" .version --raw-output)" + hash="$(nix-prefetch fetchzip --url "$(jq <<<"$resp" .url --raw-output)")" + update-source-version heroku "$version" "$hash" "$url" + ''; + meta = { homepage = "https://devcenter.heroku.com/articles/heroku-cli"; description = "Everything you need to get started using Heroku";