box-cli: init at 0.1.112

This commit is contained in:
pwnwriter
2026-06-26 09:03:16 -04:00
parent cb19bd309b
commit 9f7747b8ee
4 changed files with 91 additions and 26 deletions
+12 -4
View File
@@ -6,17 +6,23 @@
}:
let
sources = import ./sources.nix;
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";
version = "0.1.112";
inherit (sources) version;
strictDeps = true;
__structuredAttrs = true;
src = fetchurl sources.${stdenv.hostPlatform.system};
src = fetchurl {
url = "https://github.com/ariana-dot-dev/agent-server/releases/download/${sources.tag}/${platform.filename}";
inherit (platform) hash;
};
dontUnpack = true;
@@ -30,6 +36,8 @@ stdenv.mkDerivation (finalAttrs: {
runHook postInstall
'';
passthru.updateScript = ./update.sh;
meta = {
description = "CLI for Ascii Box cloud sandboxes";
homepage = "https://ascii.dev";
@@ -37,6 +45,6 @@ stdenv.mkDerivation (finalAttrs: {
sourceProvenance = [ lib.sourceTypes.binaryNativeCode ];
maintainers = with lib.maintainers; [ pwnwriter ];
mainProgram = "box";
platforms = lib.attrNames sources;
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="
}
}
}
-22
View File
@@ -1,22 +0,0 @@
# NOTE:
# To update: run `nix-prefetch-url` for each platform URL and convert to SRI hash.
# URLs: https://ascii.dev/api/box/cli/download?platform={platform}&channel=ascii-prod
# Last updated: 2026-06-26
{
x86_64-linux = {
url = "https://ascii.dev/api/box/cli/download?platform=linux-x64&channel=ascii-prod";
hash = "sha256-DWQNenz/pmFVH5QM554lBk6+RwgOCjCBe7p+ZkHADTI=";
};
aarch64-linux = {
url = "https://ascii.dev/api/box/cli/download?platform=linux-arm64&channel=ascii-prod";
hash = "sha256-V2Sk6C1ZTRWlYQ2bVQTvK6PU8BkBPkmJMjUAo2Ul6+Q=";
};
x86_64-darwin = {
url = "https://ascii.dev/api/box/cli/download?platform=darwin-x64&channel=ascii-prod";
hash = "sha256-QI+ecq0O4dkKqdIvkONcYdXsS+EQLFIU35ulKGNSCRE=";
};
aarch64-darwin = {
url = "https://ascii.dev/api/box/cli/download?platform=darwin-arm64&channel=ascii-prod";
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)"