diff --git a/maintainers/maintainer-list.nix b/maintainers/maintainer-list.nix index 8276726f45e6..1e493e01edd9 100644 --- a/maintainers/maintainer-list.nix +++ b/maintainers/maintainer-list.nix @@ -28528,6 +28528,12 @@ githubId = 30677291; name = "u2x1"; }; + u3kkasha = { + email = "fida.waseque@gmail.com"; + github = "u3kkasha"; + githubId = 146055002; + name = "Fida Waseque Choudhury"; + }; uakci = { name = "uakci"; email = "git@uakci.space"; diff --git a/pkgs/by-name/an/antigravity-cli/package.nix b/pkgs/by-name/an/antigravity-cli/package.nix new file mode 100644 index 000000000000..de1bd19ddd11 --- /dev/null +++ b/pkgs/by-name/an/antigravity-cli/package.nix @@ -0,0 +1,76 @@ +{ + lib, + stdenv, + fetchzip, + autoPatchelfHook, + versionCheckHook, +}: + +let + # Version and platform-specific data retrieved from Google's manifests + version = "1.0.2"; + + sources = { + "x86_64-linux" = { + url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.2-6109799369277440/linux-x64/cli_linux_x64.tar.gz"; + hash = "sha256-XAq2oHWaAe2AoAgDBb1/NvABfkodg3xYTDmTY5H9RD0="; + }; + "aarch64-linux" = { + url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.2-6109799369277440/linux-arm/cli_linux_arm64.tar.gz"; + hash = "sha256-7pj7TMHg+Z7DyWVmXOMqoM9kQkw5FxXTF+P4hGYc2hE="; + }; + "aarch64-darwin" = { + url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.2-6109799369277440/darwin-arm/cli_mac_arm64.tar.gz"; + hash = "sha256-stu8KZDa5id5wVImTgyedkIKJPdkBTagRCphoYLWUoI="; + }; + "x86_64-darwin" = { + url = "https://storage.googleapis.com/antigravity-public/antigravity-cli/1.0.2-6109799369277440/darwin-x64/cli_mac_x64.tar.gz"; + hash = "sha256-KDOEEgFhvpO9bifljSuhRKpb+J6c+q4TWmnrNAAS3A0="; + }; + }; + + source = + sources.${stdenv.hostPlatform.system} + or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); +in +stdenv.mkDerivation (finalAttrs: { + pname = "antigravity-cli"; + inherit version; + + src = fetchzip { + inherit (source) url hash; + }; + + strictDeps = true; + __structuredAttrs = true; + + nativeBuildInputs = lib.optionals stdenv.isLinux [ autoPatchelfHook ]; + + dontBuild = true; + dontConfigure = true; + + installPhase = '' + runHook preInstall + + install -Dm755 antigravity $out/bin/antigravity-cli + + runHook postInstall + ''; + + nativeInstallCheckInputs = [ versionCheckHook ]; + doInstallCheck = true; + + passthru = { + updateScript = ./update.py; + }; + + meta = { + description = "Google's Go-based terminal user interface (TUI) agent client"; + homepage = "https://antigravity.google"; + license = lib.licenses.unfree; + maintainers = with lib.maintainers; [ u3kkasha ]; + platforms = lib.attrNames sources; + mainProgram = "antigravity-cli"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + }; +}) diff --git a/pkgs/by-name/an/antigravity-cli/update.py b/pkgs/by-name/an/antigravity-cli/update.py new file mode 100755 index 000000000000..86c69f73da7c --- /dev/null +++ b/pkgs/by-name/an/antigravity-cli/update.py @@ -0,0 +1,131 @@ +#!/usr/bin/env nix-shell +#!nix-shell -i python3 -p python3 nix jq + +import re +import urllib.request +import json +import subprocess +import sys +import os +import tempfile + +MANIFEST_BASE = ( + "https://antigravity-cli-auto-updater-974169037036.us-central1.run.app/manifests" +) +PLATFORMS = { + "x86_64-linux": "linux_amd64", + "aarch64-linux": "linux_arm64", + "x86_64-darwin": "darwin_amd64", + "aarch64-darwin": "darwin_arm64", +} + + +def fetch_json(url): + req = urllib.request.Request( + url, headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)"} + ) + with urllib.request.urlopen(req) as response: + return json.loads(response.read().decode("utf-8")) + + +def get_nix_hash(url): + """Downloads, unpacks, and returns the SRI hash of the directory content.""" + with tempfile.TemporaryDirectory() as tmpdir: + archive_path = os.path.join(tmpdir, "archive.tar.gz") + unpack_path = os.path.join(tmpdir, "unpack") + os.makedirs(unpack_path) + + # Download + req = urllib.request.Request(url, headers={"User-Agent": "Mozilla/5.0"}) + with ( + urllib.request.urlopen(req) as response, + open(archive_path, "wb") as out_file, + ): + out_file.write(response.read()) + + # Unpack + subprocess.run(["tar", "-xzf", archive_path, "-C", unpack_path], check=True) + + # Hash + result = subprocess.run( + ["nix", "hash", "path", "--type", "sha256", unpack_path], + capture_output=True, + text=True, + check=True, + ) + return result.stdout.strip() + + +def main(): + # Change directory to the script's directory so paths are relative + script_dir = os.path.dirname(os.path.abspath(__file__)) + os.chdir(script_dir) + + print("Checking for updates from Google Antigravity release API...") + + # 1. Fetch the latest version from the linux_amd64 manifest + try: + manifest = fetch_json(f"{MANIFEST_BASE}/linux_amd64.json") + except Exception as e: + print(f"Error fetching manifest: {e}", file=sys.stderr) + sys.exit(1) + + latest_version = manifest["version"] + + # Read the current package.nix + package_file = "package.nix" + if not os.path.exists(package_file): + print(f"Error: Could not find package.nix in {script_dir}", file=sys.stderr) + sys.exit(1) + + with open(package_file, "r") as f: + content = f.read() + + # Extract current version + version_match = re.search(r'version\s*=\s*"([^"]*)"', content) + if not version_match: + print( + "Error: Could not parse current version from package.nix", file=sys.stderr + ) + sys.exit(1) + + current_version = version_match.group(1) + + if current_version == latest_version: + print(f"Already up to date (current version {current_version} is the latest).") + sys.exit(0) + + print(f"New version found! Updating: {current_version} -> {latest_version}") + + # 2. Update the version string in content + content = re.sub( + r'(version\s*=\s*")[^"]*(";)', f"\\g<1>{latest_version}\\g<2>", content + ) + + # 3. For each platform, fetch url and hash, and update sources + for platform, manifest_name in PLATFORMS.items(): + print(f"Fetching manifest for {platform}...") + try: + m = fetch_json(f"{MANIFEST_BASE}/{manifest_name}.json") + except Exception as e: + print(f"Error fetching manifest for {platform}: {e}", file=sys.stderr) + sys.exit(1) + + url = m["url"] + sri_hash = get_nix_hash(url) + + # Regex to locate and replace URL and hash for this specific platform in package.nix + pattern = rf'("{platform}"\s*=\s*\{{[^}}]+url\s*=\s*")[^"]*(";[^}}]+hash\s*=\s*")[^"]*(";)' + replacement = f"\\g<1>{url}\\g<2>{sri_hash}\\g<3>" + + content = re.sub(pattern, replacement, content) + + # Write the updated content back + with open(package_file, "w") as f: + f.write(content) + + print(f"Successfully updated package.nix to version {latest_version}!") + + +if __name__ == "__main__": + main()