sprite: init at 0.0.1-rc41

This commit is contained in:
Clément
2026-03-16 21:22:09 -07:00
parent b847d7bc1e
commit 152174f779
2 changed files with 101 additions and 0 deletions
+54
View File
@@ -0,0 +1,54 @@
{
lib,
stdenv,
fetchurl,
versionCheckHook,
autoPatchelfHook,
writableTmpDirAsHomeHook,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "sprite";
version = "0.0.1-rc41";
src = fetchurl {
url = "https://sprites-binaries.t3.storage.dev/client/v${finalAttrs.version}/sprite-${
if stdenv.hostPlatform.isLinux then "linux" else "darwin"
}-${if stdenv.hostPlatform.isx86_64 then "amd64" else "arm64"}.tar.gz";
hash =
{
aarch64-darwin = "sha256-WVEa0NjpoeHZtn8p8k5AJLifIZWgPchpyrj5ikRupoI=";
x86_64-darwin = "sha256-zwCgZSFeFFk49blOjzH5PEv5fuFUlnP/Bre0uJpz78c=";
aarch64-linux = "sha256-PjL4usgcx3ybLB7ZLPfKHaqygWVfiuCNrERbYrDRZYk=";
x86_64-linux = "sha256-PAnnP5M9lLwC3Qhydz3Bo0uLtX6uE5cJF4lDOGfsiDk=";
}
.${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
};
sourceRoot = ".";
nativeBuildInputs = lib.optional stdenv.hostPlatform.isLinux autoPatchelfHook;
installPhase = ''
mkdir -p $out/bin
install -m 755 sprite $out/bin/
'';
passthru.updateScript = ./update.sh;
nativeInstallCheckInputs = [
versionCheckHook
writableTmpDirAsHomeHook
];
versionCheckProgramArg = "--version";
versionCheckKeepEnvironment = "HOME";
doInstallCheck = true;
meta = {
description = "Command Line Interactive for sprites, stateful sandbox environments with checkpoint & restore";
homepage = "https://sprites.dev";
license = lib.licenses.unfree;
mainProgram = "sprite";
platforms = lib.platforms.linux ++ lib.platforms.darwin;
maintainers = with lib.maintainers; [ drawbu ];
};
})
+47
View File
@@ -0,0 +1,47 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused nix-prefetch
set -o errexit
set -o nounset
set -o pipefail
dirname="$(dirname "$0")"
updateHash()
{
version=$1
archHash=$2
filetype=$3
url="https://sprites-binaries.t3.storage.dev/client/v$version/sprite-$filetype.tar.gz"
hash=$(nix-prefetch-url --type sha256 "$url")
sriHash="$(nix hash convert sha256:"$hash")"
sed -i "s|$archHash = \"[a-zA-Z0-9\/+-=]*\";|$archHash = \"$sriHash\";|g" "$dirname/package.nix"
}
updateVersion()
{
sed -i "s/version = \".*\";/version = \"$1\";/g" "$dirname/package.nix"
}
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; sprite.version" | tr -d '"')
# right now, the release channel returns an error, because no "stable" version
# has been released; we have to rely on the release candidate for now.
# TODO: drop /rc.txt when a release hits stable
latestTag=$(curl -f https://sprites-binaries.t3.storage.dev/client/release.txt \
|| curl -f https://sprites-binaries.t3.storage.dev/client/rc.txt)
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "sprite is up-to-date: ${currentVersion}"
exit 0
fi
updateVersion "$latestVersion"
updateHash "$latestVersion" x86_64-linux linux-amd64
updateHash "$latestVersion" aarch64-linux linux-arm64
updateHash "$latestVersion" x86_64-darwin darwin-amd64
updateHash "$latestVersion" aarch64-darwin darwin-arm64