···11+#!/usr/bin/env nix-shell
22+#!nix-shell -i bash -p curl gnugrep gnused jq
33+# shellcheck shell=bash
44+55+set -euo pipefail
66+77+# Script configuration
88+SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
99+PACKAGE_NIX="${SCRIPT_DIR}/package.nix"
1010+SOURCES_JSON="${SCRIPT_DIR}/sources.json"
1111+1212+# Platform configuration
1313+declare -A PLATFORM_URLS=(
1414+ ["x86_64-linux"]="https://prod.download.desktop.kiro.dev/stable/metadata-linux-x64-stable.json"
1515+ ["x86_64-darwin"]="https://prod.download.desktop.kiro.dev/stable/metadata-dmg-darwin-x64-stable.json"
1616+ ["aarch64-darwin"]="https://prod.download.desktop.kiro.dev/stable/metadata-dmg-darwin-arm64-stable.json"
1717+)
1818+1919+# Data storage
2020+declare -A platform_versions
2121+declare -A platform_urls
2222+declare -A platform_hashes
2323+2424+# Error handling
2525+error_exit() {
2626+ echo "Error: $1" >&2
2727+ exit 1
2828+}
2929+3030+# Script execution starts here
3131+echo "Starting Kiro update process..."
3232+3333+# Fetch metadata for all platforms
3434+echo "Fetching platform information..."
3535+for platform in "${!PLATFORM_URLS[@]}"; do
3636+ url="${PLATFORM_URLS[$platform]}"
3737+ echo "Fetching metadata for $platform..."
3838+3939+ if ! response=$(curl -fsSL "$url"); then
4040+ error_exit "Failed to fetch metadata for $platform from $url"
4141+ fi
4242+4343+ # Extract file URL and version from metadata
4444+ file_url=$(echo "$response" | jq -r '
4545+ .releases[0].updateTo
4646+ | select(.url | test("\\.(tar|dmg)(\\.|$)"))
4747+ | .url' | head -1)
4848+4949+ if [[ -z "$file_url" || "$file_url" == "null" ]]; then
5050+ error_exit "Could not find a valid file URL for $platform in metadata"
5151+ fi
5252+5353+ version=$(echo "$response" | jq -r '.currentRelease')
5454+ if [[ -z "$version" || "$version" == "null" ]]; then
5555+ error_exit "Could not extract version for $platform from metadata"
5656+ fi
5757+5858+ platform_versions["$platform"]="$version"
5959+ platform_urls["$platform"]="$file_url"
6060+done
6161+6262+# Determine the maximum version
6363+max_version=""
6464+for platform in "${!platform_versions[@]}"; do
6565+ version="${platform_versions[$platform]}"
6666+ if [[ -z "$max_version" ]] || [[ "$version" > "$max_version" ]]; then
6767+ max_version="$version"
6868+ fi
6969+done
7070+echo "Latest version across all platforms: $max_version"
7171+7272+# Check if update is needed
7373+if [[ ! -f "$PACKAGE_NIX" ]]; then
7474+ error_exit "package.nix not found at $PACKAGE_NIX"
7575+fi
7676+current_version=$(grep -E '^ version = ' "$PACKAGE_NIX" | cut -d'"' -f2)
7777+if [[ -z "$current_version" ]]; then
7878+ error_exit "Could not extract current version from package.nix"
7979+fi
8080+if [[ "$max_version" == "$current_version" ]]; then
8181+ echo "No update needed. Current version is already the latest: $current_version"
8282+ exit 0
8383+fi
8484+8585+echo "Updating to version: $max_version"
8686+echo "Calculating hashes..."
8787+for platform in "${!platform_urls[@]}"; do
8888+ echo " Calculating hash for $platform..."
8989+ platform_hashes["$platform"]=$(nix hash convert --hash-algo sha256 "$(nix-prefetch-url "${platform_urls[$platform]}")")
9090+done
9191+9292+# Update package.nix and generate sources.json
9393+echo "Updating package.nix..."
9494+sed -i "s/version = \".*\"/version = \"$max_version\"/" "$PACKAGE_NIX"
9595+9696+echo "Generating sources.json..."
9797+json_content="{}"
9898+for platform in "${!platform_urls[@]}"; do
9999+ json_content=$(echo "$json_content" | jq --arg platform "$platform" \
100100+ --arg url "${platform_urls[$platform]}" \
101101+ --arg hash "${platform_hashes[$platform]}" \
102102+ '. + {($platform): {url: $url, hash: $hash}}')
103103+done
104104+echo "$json_content" >"$SOURCES_JSON"
105105+106106+echo "Successfully updated package.nix to version $max_version"
107107+echo "Hashes calculated and updated:"
108108+for platform in "${!platform_hashes[@]}"; do
109109+ echo " $platform: ${platform_hashes[$platform]}"
110110+done
+6
pkgs/top-level/all-packages.nix
···1380713807 nodejs = nodejs_20;
1380813808 };
13809138091381013810+ kiro = callPackage ../by-name/ki/kiro/package.nix {
1381113811+ vscode-generic = ../applications/editors/vscode/generic.nix;
1381213812+ };
1381313813+ kiro-fhs = kiro.fhs;
1381413814+ kiro-fhsWithPackages = kiro.fhsWithPackages;
1381513815+1381013816 whispers = with python3Packages; toPythonApplication whispers;
13811138171381213818 # Should always be the version with the most features