Unverified Commit b8de0d28 authored by Philip Taron's avatar Philip Taron Committed by GitHub
Browse files

cursor-cli: init at 0-unstable-2025-08-22 (#432035)

parents 242c91c0 4cd81eaa
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -1587,6 +1587,12 @@
    githubId = 587021;
    name = "André V L Matos";
  };
  andrewbastin = {
    email = "andrewbastin.k@gmail.com";
    github = "AndrewBastin";
    githubId = 9131943;
    name = "Andrew Bastin";
  };
  andrewchambers = {
    email = "ac@acha.ninja";
    github = "andrewchambers";
+67 −0
Original line number Diff line number Diff line
{
  lib,
  fetchurl,
  stdenv,
  autoPatchelfHook,
}:

let
  inherit (stdenv) hostPlatform;
  sources = {
    x86_64-linux = fetchurl {
      url = "https://downloads.cursor.com/lab/2025.08.22-82fb571/linux/x64/agent-cli-package.tar.gz";
      hash = "sha256-jfjYWM9Vuq9sYZcnqiap3TKuVWHHKt/aF7XaVilJjsE=";
    };
    aarch64-linux = fetchurl {
      url = "https://downloads.cursor.com/lab/2025.08.22-82fb571/linux/arm64/agent-cli-package.tar.gz";
      hash = "sha256-uMK5jO77TQntsrR450WWBj9q5VBowNUhO6UkZ/z1ys4=";
    };
    x86_64-darwin = fetchurl {
      url = "https://downloads.cursor.com/lab/2025.08.22-82fb571/darwin/x64/agent-cli-package.tar.gz";
      hash = "sha256-gFM+igXGdLLJXVHAou6pRTIVqsg6iPagaghBAzRcPXw=";
    };
    aarch64-darwin = fetchurl {
      url = "https://downloads.cursor.com/lab/2025.08.22-82fb571/darwin/arm64/agent-cli-package.tar.gz";
      hash = "sha256-XN2QaFt/lbVHfFfdZaznRvUlMWIHq7nUbe3uptrGjN0=";
    };
  };
in
stdenv.mkDerivation {
  pname = "cursor-cli";
  version = "0-unstable-2025-08-22";

  src = sources.${hostPlatform.system};

  nativeBuildInputs = lib.optionals hostPlatform.isLinux [
    autoPatchelfHook
    stdenv.cc.cc.lib
  ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin $out/share/cursor-agent
    cp -r * $out/share/cursor-agent/
    ln -s $out/share/cursor-agent/cursor-agent $out/bin/cursor-agent

    runHook postInstall
  '';

  passthru = {
    inherit sources;
    updateScript = ./update.sh;
  };

  meta = {
    description = "Cursor CLI";
    homepage = "https://cursor.com/cli";
    license = lib.licenses.unfree;
    maintainers = with lib.maintainers; [
      sudosubin
      andrewbastin
    ];
    platforms = builtins.attrNames sources;
    mainProgram = "cursor-agent";
    sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
  };
}
+32 −0
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl coreutils common-updater-scripts
set -eu -o pipefail

release=$(curl -s https://cursor.com/install | grep -oP "lab/\K[^/]+")

# Check if release matches the pattern YYYY.MM.DD-{commithash}
if [[ "$release" =~ ^[0-9]{4}\.[0-9]{2}\.[0-9]{2}-[a-f0-9]+$ ]]; then
  timestamp=$(echo "$release" | cut -d"-" -f1 | tr "." "-")
  latestVersion="0-unstable-$timestamp"
else
  latestVersion="$release"
fi

currentVersion=$(nix eval --raw -f . cursor-cli.version)

echo "latest  version: $latestVersion"
echo "current version: $currentVersion"

if [[ "$latestVersion" == "$currentVersion" ]]; then
  echo "package is up-to-date"
  exit 0
fi

declare -A platforms=( [x86_64-linux]="linux/x64" [aarch64-linux]="linux/arm64" [x86_64-darwin]="darwin/x64" [aarch64-darwin]="darwin/arm64" )

for platform in "${!platforms[@]}"; do
  url="https://downloads.cursor.com/lab/$release/${platforms[$platform]}/agent-cli-package.tar.gz"
  source=$(nix-prefetch-url "$url" --name "cursor-cli-$latestVersion")
  hash=$(nix-hash --to-sri --type sha256 "$source")
  update-source-version cursor-cli "$latestVersion" "$hash" "$url" --system="$platform" --source-key="sources.$platform" --ignore-same-version
done