fermyon-spin: 3.0.0 -> 3.5.0; add updateScript

[Release on GitHub](https://github.com/spinframework/spin/releases/tag/v3.5.0)
[Compare changes on GitHub](https://github.com/spinframework/spin/compare/v3.0.0...v3.5.0)
This commit is contained in:
Michael Daniels
2025-09-16 21:16:19 -04:00
parent fa21fb7cd8
commit 388f15513e
3 changed files with 74 additions and 48 deletions

View File

@@ -19,27 +19,24 @@ let
}
.${system} or (throw "Unsupported system: ${system}");
# TODO: It'd be nice to write an update script that would update all of these
# hashes together.
packageHash =
{
x86_64-linux = "sha256-r/F3Tj3WeeL2R27ussX+ebFWpW+8z2e7tdBK4MHFMpk=";
aarch64-linux = "sha256-BSFxDJeY7fOOxDqAV+6FJf0hup1Y5IJ/czqwc4W7qSA=";
x86_64-darwin = "sha256-T6J9IjfXdt9DnZksndAmZRkYyH/5H60J7V6xU0ltD2A=";
aarch64-darwin = "sha256-6x+0PB5/2oqYDVNiNhc0xcs/ESCLvvSsWtm2KlTIeBo=";
}
.${system} or (throw "Unsupported system: ${system}");
packageHashes = {
x86_64-linux = "sha256-TWWT60H8KtZlJTRY+RnS2pP7r0eKBDzGVm890uGdtHU=";
aarch64-linux = "sha256-MBZ/AgUz5dg8tFj4q+alnwlHu3d6/rfYZk9B1jYnGbw=";
x86_64-darwin = "sha256-F2wgyyf0L2Ci5MV0VQD5CnjckudbgvQEpNbZUIkw9Gc=";
aarch64-darwin = "sha256-9Onvzsc2UInjgX9AeWMFNvpUv2Y4i5wUR6z3Igyrzy0=";
};
packageHash = packageHashes.${system} or (throw "Unsupported system: ${system}");
in
stdenv.mkDerivation rec {
pname = "fermyon-spin";
version = "3.0.0";
version = "3.5.0";
# 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";
url = "https://github.com/spinframework/spin/releases/download/v${version}/spin-v${version}-${platform}.tar.gz";
hash = packageHash;
};
@@ -63,13 +60,18 @@ stdenv.mkDerivation rec {
runHook postInstall
'';
meta = with lib; {
passthru = {
inherit packageHashes; # needed by updateScript
updateScript = ./update.py;
};
meta = {
description = "Framework for building, deploying, and running fast, secure, and composable cloud microservices with WebAssembly";
homepage = "https://github.com/fermyon/spin";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
license = with licenses; [ asl20 ];
homepage = "https://github.com/spinframework/spin";
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
license = with lib.licenses; [ asl20 ];
mainProgram = "spin";
maintainers = [ ];
platforms = platforms.linux ++ platforms.darwin;
platforms = builtins.attrNames packageHashes;
};
}

View File

@@ -0,0 +1,55 @@
#!/usr/bin/env nix-shell
#!nix-shell -i python3 -p python3 bash nix-update jq
import subprocess
from os.path import join, dirname
# Outer keys are as in Nix, the inner dict's values are as in upstream.
# We set oldHash and newHash fields in the inner dict later.
systems = {
"x86_64-linux": {"os": "linux", "arch": "amd64"},
"x86_64-darwin": {"os": "macos", "arch": "amd64"},
"aarch64-linux": {"os": "linux", "arch": "aarch64"},
"aarch64-darwin": {"os": "macos", "arch": "aarch64"},
}
# This will set the version correctly,
# and will also set the hash for one of the systems.
subprocess.run([
"nix-update",
"fermyon-spin",
"--version-regex",
r"^v([\d\.]*)",
"--url",
"https://github.com/spinframework/spin"
])
newVer = subprocess.run(
["nix-instantiate", "--eval", "--raw", "-A", "fermyon-spin.version"], capture_output=True, encoding="locale"
).stdout
for nixTuple in systems:
url = (
"https://github.com/spinframework/spin/releases/download/v"
f"{newVer}/spin-v{newVer}-{systems[nixTuple]['os']}-{systems[nixTuple]['arch']}.tar.gz"
)
systems[nixTuple]["oldHash"] = subprocess.run(
["nix-instantiate", "--eval", "--raw", "-A", f"fermyon-spin.passthru.packageHashes.{nixTuple}"],
capture_output=True,
encoding="locale",
).stdout
systems[nixTuple]["newHash"] = subprocess.run(
["bash", "-c", f"nix store prefetch-file {url} --json | jq -r '.hash'"],
capture_output=True,
encoding="locale",
).stdout.strip() # Has a newline
with open(join(dirname(__file__), "package.nix"), "r") as f:
file = f.read()
for nixTuple in systems:
file = file.replace(systems[nixTuple]["oldHash"], systems[nixTuple]["newHash"])
with open(join(dirname(__file__), "package.nix"), "w") as f:
f.write(file)

View File

@@ -1,31 +0,0 @@
#!/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