Commit cee55b8b authored by Vuks69's avatar Vuks69 Committed by Masum Reza
Browse files

kiro: init at 0.2.13

parent 74b034b5
Loading
Loading
Loading
Loading
+60 −0
Original line number Diff line number Diff line
{
  lib,
  stdenv,
  callPackage,
  vscode-generic,
  fetchurl,
  extraCommandLineArgs ? "",
  useVSCodeRipgrep ? stdenv.hostPlatform.isDarwin,
}:

let
  sources = (lib.importJSON ./sources.json).${stdenv.hostPlatform.system};
in
(callPackage vscode-generic {
  inherit useVSCodeRipgrep;
  commandLineArgs = extraCommandLineArgs;

  version = "0.2.13";
  pname = "kiro";

  # You can find the current VSCode version in the About dialog:
  # workbench.action.showAboutDialog (Help: About)
  vscodeVersion = "1.94.0";

  executableName = "kiro";
  longName = "Kiro";
  shortName = "kiro";
  libraryName = "kiro";
  iconName = "kiro";

  src = fetchurl {
    url = sources.url;
    hash = sources.hash;
  };
  sourceRoot = "Kiro";
  patchVSCodePath = true;

  tests = { };
  updateScript = ./update.sh;

  meta = {
    description = "IDE for Agentic AI workflows based on VS Code";
    homepage = "https://kiro.dev";
    license = lib.licenses.amazonsl;
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
    maintainers = with lib.maintainers; [ vuks ];
    platforms = [
      "x86_64-linux"
      "x86_64-darwin"
      "aarch64-darwin"
    ];
    mainProgram = "kiro";
  };

}).overrideAttrs
  (oldAttrs: {
    passthru = (oldAttrs.passthru or { }) // {
      inherit sources;
    };
  })
+14 −0
Original line number Diff line number Diff line
{
  "x86_64-linux": {
    "url": "https://prod.download.desktop.kiro.dev/releases/202508150626--distro-linux-x64-tar-gz/202508150626-distro-linux-x64.tar.gz",
    "hash": "sha256-ORgN7gOyHGkO/ewqy62H0oNweZz7ViUAuEtXM1WgYIE="
  },
  "x86_64-darwin": {
    "url": "https://prod.download.desktop.kiro.dev/releases/202508150626-Kiro-dmg-darwin-x64.dmg",
    "hash": "sha256-8lIiMfDxp8VuRG/tiuojtOksc6oGT0+ZPpSAriRmKYU="
  },
  "aarch64-darwin": {
    "url": "https://prod.download.desktop.kiro.dev/releases/202508150626-Kiro-dmg-darwin-arm64.dmg",
    "hash": "sha256-2WGLIspDErwa1CZmSTTFa4aNCi6T/8x3vDNalNsm4xQ="
  }
}
+110 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnugrep gnused jq
# shellcheck shell=bash

set -euo pipefail

# Script configuration
SCRIPT_DIR="$(dirname "$(readlink -f "$0")")"
PACKAGE_NIX="${SCRIPT_DIR}/package.nix"
SOURCES_JSON="${SCRIPT_DIR}/sources.json"

# Platform configuration
declare -A PLATFORM_URLS=(
    ["x86_64-linux"]="https://prod.download.desktop.kiro.dev/stable/metadata-linux-x64-stable.json"
    ["x86_64-darwin"]="https://prod.download.desktop.kiro.dev/stable/metadata-dmg-darwin-x64-stable.json"
    ["aarch64-darwin"]="https://prod.download.desktop.kiro.dev/stable/metadata-dmg-darwin-arm64-stable.json"
)

# Data storage
declare -A platform_versions
declare -A platform_urls
declare -A platform_hashes

# Error handling
error_exit() {
    echo "Error: $1" >&2
    exit 1
}

# Script execution starts here
echo "Starting Kiro update process..."

# Fetch metadata for all platforms
echo "Fetching platform information..."
for platform in "${!PLATFORM_URLS[@]}"; do
    url="${PLATFORM_URLS[$platform]}"
    echo "Fetching metadata for $platform..."

    if ! response=$(curl -fsSL "$url"); then
        error_exit "Failed to fetch metadata for $platform from $url"
    fi

    # Extract file URL and version from metadata
    file_url=$(echo "$response" | jq -r '
        .releases[0].updateTo
        | select(.url | test("\\.(tar|dmg)(\\.|$)"))
        | .url' | head -1)

    if [[ -z "$file_url" || "$file_url" == "null" ]]; then
        error_exit "Could not find a valid file URL for $platform in metadata"
    fi

    version=$(echo "$response" | jq -r '.currentRelease')
    if [[ -z "$version" || "$version" == "null" ]]; then
        error_exit "Could not extract version for $platform from metadata"
    fi

    platform_versions["$platform"]="$version"
    platform_urls["$platform"]="$file_url"
done

# Determine the maximum version
max_version=""
for platform in "${!platform_versions[@]}"; do
    version="${platform_versions[$platform]}"
    if [[ -z "$max_version" ]] || [[ "$version" > "$max_version" ]]; then
        max_version="$version"
    fi
done
echo "Latest version across all platforms: $max_version"

# Check if update is needed
if [[ ! -f "$PACKAGE_NIX" ]]; then
    error_exit "package.nix not found at $PACKAGE_NIX"
fi
current_version=$(grep -E '^  version = ' "$PACKAGE_NIX" | cut -d'"' -f2)
if [[ -z "$current_version" ]]; then
    error_exit "Could not extract current version from package.nix"
fi
if [[ "$max_version" == "$current_version" ]]; then
    echo "No update needed. Current version is already the latest: $current_version"
    exit 0
fi

echo "Updating to version: $max_version"
echo "Calculating hashes..."
for platform in "${!platform_urls[@]}"; do
    echo "  Calculating hash for $platform..."
    platform_hashes["$platform"]=$(nix hash convert --hash-algo sha256 "$(nix-prefetch-url "${platform_urls[$platform]}")")
done

# Update package.nix and generate sources.json
echo "Updating package.nix..."
sed -i "s/version = \".*\"/version = \"$max_version\"/" "$PACKAGE_NIX"

echo "Generating sources.json..."
json_content="{}"
for platform in "${!platform_urls[@]}"; do
    json_content=$(echo "$json_content" | jq --arg platform "$platform" \
        --arg url "${platform_urls[$platform]}" \
        --arg hash "${platform_hashes[$platform]}" \
        '. + {($platform): {url: $url, hash: $hash}}')
done
echo "$json_content" >"$SOURCES_JSON"

echo "Successfully updated package.nix to version $max_version"
echo "Hashes calculated and updated:"
for platform in "${!platform_hashes[@]}"; do
    echo "  $platform: ${platform_hashes[$platform]}"
done
+6 −0
Original line number Diff line number Diff line
@@ -13807,6 +13807,12 @@ with pkgs;
    nodejs = nodejs_20;
  };

  kiro = callPackage ../by-name/ki/kiro/package.nix {
    vscode-generic = ../applications/editors/vscode/generic.nix;
  };
  kiro-fhs = kiro.fhs;
  kiro-fhsWithPackages = kiro.fhsWithPackages;

  whispers = with python3Packages; toPythonApplication whispers;

  # Should always be the version with the most features