box-cli: init at 0.1.112 (#535650)

This commit is contained in:
Gaétan Lepage
2026-06-28 12:42:31 +00:00
committed by GitHub
3 changed files with 129 additions and 0 deletions
+50
View File
@@ -0,0 +1,50 @@
{
lib,
stdenv,
fetchurl,
installShellFiles,
}:
let
sources = lib.importJSON ./sources.json;
platform =
sources.platforms.${stdenv.hostPlatform.system}
or (throw "Unsupported platform: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation (finalAttrs: {
pname = "box-cli";
inherit (sources) version;
strictDeps = true;
__structuredAttrs = true;
src = fetchurl {
url = "https://github.com/ariana-dot-dev/agent-server/releases/download/${sources.tag}/${platform.filename}";
inherit (platform) hash;
};
dontUnpack = true;
nativeBuildInputs = [ installShellFiles ];
installPhase = ''
runHook preInstall
install -Dm755 $src $out/bin/box
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = {
description = "CLI for Ascii Box cloud sandboxes";
homepage = "https://ascii.dev";
license = lib.licenses.unfree;
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
maintainers = with lib.maintainers; [ pwnwriter ];
mainProgram = "box";
platforms = lib.attrNames sources.platforms;
};
})
+22
View File
@@ -0,0 +1,22 @@
{
"version": "0.1.112",
"tag": "box-cli-v0.1.112-ascii-prod1",
"platforms": {
"x86_64-linux": {
"filename": "box-linux-x64",
"hash": "sha256-DWQNenz/pmFVH5QM554lBk6+RwgOCjCBe7p+ZkHADTI="
},
"aarch64-linux": {
"filename": "box-linux-arm64",
"hash": "sha256-V2Sk6C1ZTRWlYQ2bVQTvK6PU8BkBPkmJMjUAo2Ul6+Q="
},
"x86_64-darwin": {
"filename": "box-darwin-x64",
"hash": "sha256-QI+ecq0O4dkKqdIvkONcYdXsS+EQLFIU35ulKGNSCRE="
},
"aarch64-darwin": {
"filename": "box-darwin-arm64",
"hash": "sha256-cyjMUGkWfNOggvtBfVqCijmcAj0P2SuFQORwg9EWbn0="
}
}
}
+57
View File
@@ -0,0 +1,57 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl jq nix
set -euo pipefail
cd "$(dirname "$0")"
channel="ascii-prod"
repo="ariana-dot-dev/agent-server"
old_version=$(jq -r ".version" sources.json)
tag=$(curl -s ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} \
"https://api.github.com/repos/${repo}/git/refs/tags/box-cli-v" \
| jq -r --arg channel "$channel" \
'[.[].ref | select(test($channel)) | ltrimstr("refs/tags/")] | sort_by(split(".")[2] | tonumber) | last')
if [[ -z "$tag" || "$tag" == "null" ]]; then
echo "No box-cli release found for channel $channel"
exit 1
fi
version=$(echo "$tag" | sed -n 's/^box-cli-v\([0-9.]*\)-.*/\1/p')
if [[ "$old_version" == "$version" ]]; then
echo "box-cli is already up to date at $version"
exit 0
fi
echo "Updating box-cli from $old_version to $version"
declare -A platforms=(
[x86_64-linux]="box-linux-x64"
[aarch64-linux]="box-linux-arm64"
[x86_64-darwin]="box-darwin-x64"
[aarch64-darwin]="box-darwin-arm64"
)
sources_tmp="$(mktemp)"
jq -n --arg v "$version" --arg t "$tag" '{version: $v, tag: $t, platforms: {}}' > "$sources_tmp"
for platform in "${!platforms[@]}"; do
filename="${platforms[$platform]}"
url="https://github.com/${repo}/releases/download/${tag}/${filename}"
echo "Fetching hash for $platform ($filename)..."
sha256hash="$(nix-prefetch-url --type sha256 "$url")"
hash="$(nix hash convert --to sri --hash-algo sha256 "$sha256hash")"
jq --arg platform "$platform" \
--arg filename "$filename" \
--arg hash "$hash" \
'.platforms += {($platform): {filename: $filename, hash: $hash}}' \
"$sources_tmp" > "${sources_tmp}.tmp" && mv "${sources_tmp}.tmp" "$sources_tmp"
done
mv "$sources_tmp" sources.json
echo "Updated box-cli to $version (tag: $tag)"