antigravity-cli: clean up derivation and updateScript (#527053)

This commit is contained in:
Michael Daniels
2026-06-08 21:28:21 +00:00
committed by GitHub
2 changed files with 46 additions and 92 deletions
+27 -42
View File
@@ -1,58 +1,50 @@
{
lib,
stdenv,
fetchzip,
stdenvNoCC,
fetchurl,
autoPatchelfHook,
versionCheckHook,
}:
let
# Version and platform-specific data retrieved from Google's manifests
version = "1.0.6";
wholeVersion = "1.0.7-5858071034068992"; # unfortunately this has dumb versioning
version = builtins.head (lib.splitString "-" wholeVersion);
throwSystem = throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}";
sourceData = {
"x86_64-linux" = {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.6-5359777384103936/linux-x64/cli_linux_x64.tar.gz";
hash = "sha256-rxDLuuium+yQl3SiRcFhLzC5+ZCZU/tG2LQfFZMOYx4=";
x86_64-linux = fetchurl {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/${wholeVersion}/linux-x64/cli_linux_x64.tar.gz";
hash = "sha256-8kaHmc0XPAPuATHb4rrkMhUzBqaLqi7n1UQPFcRB4Go=";
};
"aarch64-linux" = {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.6-5359777384103936/linux-arm/cli_linux_arm64.tar.gz";
hash = "sha256-Mol5V3Lt2A89yrGdwWiOdv4y5dCZkMaT8onXG6IsQtc=";
aarch64-linux = fetchurl {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/${wholeVersion}/linux-arm/cli_linux_arm64.tar.gz";
hash = "sha256-3ylG6ZW/9AuKydzzyMLtqC1ec2NnixFG/CJih26S0K0=";
};
"aarch64-darwin" = {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.6-5359777384103936/darwin-arm/cli_mac_arm64.tar.gz";
hash = "sha256-GmAxVP6KW0Zii2kSDvwwzsa88r/4ko2BVVpS8BeING4=";
aarch64-darwin = fetchurl {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/${wholeVersion}/darwin-arm/cli_mac_arm64.tar.gz";
hash = "sha256-e4VhL/9rUNgE2XyW8REz8QXEbzwsUFg41xNpUHfNLK0=";
};
"x86_64-darwin" = {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.6-5359777384103936/darwin-x64/cli_mac_x64.tar.gz";
hash = "sha256-RqjKhRqiW6Fg61eYzem+uXb5LXBYi5Cyv0hwtCaqomo=";
x86_64-darwin = fetchurl {
url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/${wholeVersion}/darwin-x64/cli_mac_x64.tar.gz";
hash = "sha256-SECE7bAd0VneVeAvBs14Ortkcqg8CJy9xcq3ZnuqfKY=";
};
};
sources = lib.mapAttrs (
_system: source:
fetchzip {
inherit (source) url hash;
}
) sourceData;
source =
sources.${stdenv.hostPlatform.system}
or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
in
stdenv.mkDerivation (finalAttrs: {
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "antigravity-cli";
inherit version;
src = source;
strictDeps = true;
__structuredAttrs = true;
nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ];
src = sourceData.${stdenvNoCC.hostPlatform.system} or throwSystem;
sourceRoot = ".";
nativeBuildInputs = lib.optionals stdenvNoCC.hostPlatform.isLinux [ autoPatchelfHook ];
dontBuild = true;
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
@@ -66,15 +58,8 @@ stdenv.mkDerivation (finalAttrs: {
doInstallCheck = true;
passthru = {
inherit sources;
updateScript = [
./update.sh
version
]
++ lib.concatMap (system: [
system
sourceData.${system}.url
]) (lib.attrNames sourceData);
inherit wholeVersion; # for the updateScript
updateScript = ./update.sh;
};
meta = {
+19 -50
View File
@@ -1,60 +1,29 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash common-updater-scripts coreutils curl gnutar nix
# shellcheck shell=bash
#!nix-shell -i bash -p bash nix-update common-updater-scripts nix jq
set -euo pipefail
script_dir="$(cd -- "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
nixpkgs_root="$(realpath "$script_dir/../../../..")"
package_file="$script_dir/package.nix"
tmpdir="$(mktemp -d)"
trap 'rm -rf "$tmpdir"' EXIT
baseUrl=https://storage.googleapis.com/antigravity-public/antigravity-cli
cd -- "$nixpkgs_root"
currentVersion=$(nix-instantiate --eval --raw -E "with import ./. {}; antigravity-cli.version or (lib.getVersion antigravity-cli)")
latestVersion=$(curl $baseUrl/latest)
if (( $# < 3 || ($# - 1) % 2 != 0 )); then
echo "Usage: $0 <version> [<system> <url>]..." >&2
exit 1
if [[ "$currentVersion" == "$latestVersion" ]]; then
echo "package is up-to-date: $currentVersion"
exit 0
fi
version="$1"
shift
# urls unfortunately include a weird buildid that make it hard to get
latestWholeVersion=$(curl $baseUrl/$latestVersion/manifest.json | jq -r '.platforms."linux-x64".url' | cut -d/ -f6)
export NIXPKGS_ALLOW_UNFREE=1
update-source-version --version-key=wholeVersion antigravity-cli $latestWholeVersion || true
hash_url() {
local system="$1"
local url="$2"
local archive="$tmpdir/$system.tar.gz"
local unpack_dir="$tmpdir/$system-unpack"
mkdir -p "$unpack_dir"
curl -fsSL "$url" -o "$archive" || return
tar -xzf "$archive" -C "$unpack_dir" || return
if [[ ! -x "$unpack_dir/antigravity" ]]; then
echo "Expected executable 'antigravity' in $url" >&2
exit 1
fi
nix hash path --type sha256 "$unpack_dir"
}
while (( $# > 0 )); do
system="$1"
url="$2"
shift 2
if [[ "$url" != *"/antigravity-cli/$version-"* ]]; then
echo "URL for $system does not match package version $version: $url" >&2
exit 1
fi
echo "Hashing $system from $url"
hash="$(hash_url "$system" "$url")"
update-source-version antigravity-cli "$version" "$hash" \
--file="$package_file" \
--ignore-same-hash \
--ignore-same-version \
--source-key="sources.$system" \
--system="$system"
for system in \
x86_64-linux \
aarch64-linux \
x86_64-darwin \
aarch64-darwin; do
hash=$(nix store prefetch-file --json --hash-type sha256 \
$(nix-instantiate --eval --raw -E "with import ./. {}; antigravity-cli.src.url" --system "$system") | jq -r '.hash')
update-source-version --version-key=wholeVersion antigravity-cli $latestWholeVersion $hash --system=$system --ignore-same-version
done