From cd851f5499fc4600a9febe8347edd333d8bc9b1f Mon Sep 17 00:00:00 2001 From: Danielle Lancashire Date: Wed, 17 Apr 2024 21:37:52 +0000 Subject: [PATCH] fermyon-spin: 2.2.0 -> 2.4.2 Signed-off-by: Danielle Lancashire --- .../tools/fermyon-spin/default.nix | 22 +++++++------ pkgs/development/tools/fermyon-spin/update.sh | 31 +++++++++++++++++++ 2 files changed, 44 insertions(+), 9 deletions(-) create mode 100755 pkgs/development/tools/fermyon-spin/update.sh diff --git a/pkgs/development/tools/fermyon-spin/default.nix b/pkgs/development/tools/fermyon-spin/default.nix index 8091c64b974b..a969baf411f8 100644 --- a/pkgs/development/tools/fermyon-spin/default.nix +++ b/pkgs/development/tools/fermyon-spin/default.nix @@ -1,6 +1,6 @@ { lib , stdenv -, fetchzip +, fetchurl , autoPatchelfHook , gcc-unwrapped , zlib @@ -17,22 +17,26 @@ let }.${system} or (throw "Unsupported system: ${system}"); packageHash = { - x86_64-linux = "sha256-Y0Inew0PncpnEpdLWtl/85t93eGSRewKh5mvGnn+yck="; - aarch64-linux = "sha256-HEm3TaLeaws8G73CU9BmxeplQdeF9nQbBSnbctaVhqI="; - x86_64-darwin = "sha256-mlshpN/4Od4qrXiqIEYo7G84Dtb+tp2nK2VnrRG2rto="; - aarch64-darwin = "sha256-aJH/vOidj0vbkttGDgelaAC/dMYguQPLjxl+V3pOVzI="; + x86_64-linux = "sha256-LHiLkZ+VN+wPnq6OukXozQWKh7ewNaFor1ndCUlCBtU="; + aarch64-linux = "sha256-1+rLGnm+LhbYigYUcmuLICLFXUk3wjOkmxuCuuI+Xqc="; + x86_64-darwin = "sha256-mJA3VXfNr6578Q2xw0xOZccloQpeCIsjn3dVdlsnTVs="; + aarch64-darwin = "sha256-FNl3UefJWA8yJ2B44GUEK6py7DLikJrygIwsqdIjW9c="; }.${system} or (throw "Unsupported system: ${system}"); in stdenv.mkDerivation rec { pname = "fermyon-spin"; - version = "2.2.0"; + version = "2.4.2"; - src = fetchzip { + # Use fetchurl rather than fetchzip as these tarballs are built by the project + # and not by GitHub (and thus are stable) - this simplifies the update script + # by allowing it to use the output of `nix store prefetch-file`. + src = fetchurl { url = "https://github.com/fermyon/spin/releases/download/v${version}/spin-v${version}-${platform}.tar.gz"; - stripRoot = false; hash = packageHash; }; + sourceRoot = "."; + nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ]; @@ -46,7 +50,7 @@ in stdenv.mkDerivation rec { runHook preInstall mkdir -p $out/bin - cp $src/* $out/bin + cp ./spin $out/bin runHook postInstall ''; diff --git a/pkgs/development/tools/fermyon-spin/update.sh b/pkgs/development/tools/fermyon-spin/update.sh new file mode 100755 index 000000000000..9d00621f1c37 --- /dev/null +++ b/pkgs/development/tools/fermyon-spin/update.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i bash -p jq +#shellcheck shell=bash + +CURRENT_HASH="" + +print_hash() { + OS="$1" + ARCH="$2" + VERSION="$3" + + URL="https://github.com/fermyon/spin/releases/download/v${VERSION}/spin-v${VERSION}-${OS}-${ARCH}.tar.gz" + echo + CURRENT_HASH=$(nix store prefetch-file "$URL" --json | jq -r '.hash') + + echo "${ARCH}-${OS}: $CURRENT_HASH" +} + +if [[ -z "$VER" && -n "$1" ]]; then + VER="$1" +fi + +if [[ -z "$VER" ]]; then + echo "No 'VER' environment variable provided, skipping" +else + print_hash "linux" "amd64" "$VER" + print_hash "linux" "aarch64" "$VER" + print_hash "macos" "amd64" "$VER" + print_hash "macos" "aarch64" "$VER" +fi +