Support for aarch64
This commit is contained in:
@@ -5,6 +5,10 @@ on:
|
|||||||
- cron: '0 12 * * *' # Run daily at 12:00 UTC
|
- cron: '0 12 * * *' # Run daily at 12:00 UTC
|
||||||
workflow_dispatch: # Allow manual triggering
|
workflow_dispatch: # Allow manual triggering
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: update-cursor
|
||||||
|
cancel-in-progress: true
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-cursor:
|
update-cursor:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
@@ -31,18 +35,15 @@ jobs:
|
|||||||
# Run the update script (it will auto-confirm in CI mode)
|
# Run the update script (it will auto-confirm in CI mode)
|
||||||
./update-cursor.sh
|
./update-cursor.sh
|
||||||
|
|
||||||
# Capture version info from script output
|
|
||||||
if [[ -f "$GITHUB_OUTPUT" ]]; then
|
|
||||||
grep "CURSOR_VERSION_INFO=" "$GITHUB_OUTPUT" || echo "CURSOR_VERSION_INFO=no_update" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Update flake lock file
|
- name: Update flake lock file
|
||||||
|
if: steps.update-cursor.outputs.CURSOR_VERSION_INFO != 'no_update'
|
||||||
run: |
|
run: |
|
||||||
nix flake update
|
nix flake update
|
||||||
|
|
||||||
- name: Test the updated flake
|
- name: Test the updated flake
|
||||||
|
if: steps.update-cursor.outputs.CURSOR_VERSION_INFO != 'no_update'
|
||||||
run: |
|
run: |
|
||||||
nix flake check
|
nix flake check --no-build
|
||||||
nix build .#cursor --dry-run
|
nix build .#cursor --dry-run
|
||||||
|
|
||||||
- name: Commit and push changes
|
- name: Commit and push changes
|
||||||
@@ -75,7 +76,7 @@ jobs:
|
|||||||
|
|
||||||
git config --local user.email "action@github.com"
|
git config --local user.email "action@github.com"
|
||||||
git config --local user.name "GitHub Action"
|
git config --local user.name "GitHub Action"
|
||||||
git add flake.nix flake.lock
|
git add flake.nix flake.lock cursor-release.nix
|
||||||
git commit -m "$COMMIT_MSG"
|
git commit -m "$COMMIT_MSG"
|
||||||
git push
|
git push
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ A Nix flake that provides the Cursor code editor with automatic daily updates vi
|
|||||||
- 🔧 **Manual updates**: Local script for immediate updates
|
- 🔧 **Manual updates**: Local script for immediate updates
|
||||||
- 🛡️ **Robust**: Proper error handling and fallbacks
|
- 🛡️ **Robust**: Proper error handling and fallbacks
|
||||||
- 📦 **AppImage-based**: Uses Cursor's official AppImage for maximum compatibility
|
- 📦 **AppImage-based**: Uses Cursor's official AppImage for maximum compatibility
|
||||||
- 🎯 **Linux x86_64**: Optimized for Linux AMD64 architecture
|
- 🎯 **Linux x86_64 + aarch64**: Supports both AMD64 and ARM64 (aarch64) Linux
|
||||||
|
|
||||||
## Quick Start
|
## Quick Start
|
||||||
|
|
||||||
@@ -31,18 +31,18 @@ Then use in your configuration:
|
|||||||
```nix
|
```nix
|
||||||
# For NixOS system configuration
|
# For NixOS system configuration
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
cursor.packages.x86_64-linux.cursor
|
cursor.packages.${pkgs.system}.cursor
|
||||||
];
|
];
|
||||||
|
|
||||||
# For home-manager
|
# For home-manager
|
||||||
home.packages = with pkgs; [
|
home.packages = with pkgs; [
|
||||||
cursor.packages.x86_64-linux.cursor
|
cursor.packages.${pkgs.system}.cursor
|
||||||
];
|
];
|
||||||
|
|
||||||
# For devShell
|
# For devShell
|
||||||
devShells.default = pkgs.mkShell {
|
devShells.default = pkgs.mkShell {
|
||||||
packages = with pkgs; [
|
packages = with pkgs; [
|
||||||
cursor.packages.x86_64-linux.cursor
|
cursor.packages.${pkgs.system}.cursor
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
```
|
```
|
||||||
@@ -65,6 +65,8 @@ To manually update Cursor to the latest version:
|
|||||||
./update-cursor.sh
|
./update-cursor.sh
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Note: on a fresh fork, `cursor-release.nix` may contain a placeholder aarch64 hash until you run the updater once (or trigger the GitHub Action via `workflow_dispatch`).
|
||||||
|
|
||||||
To update to a specific version:
|
To update to a specific version:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
@@ -78,9 +80,9 @@ The GitHub Actions workflow runs daily and:
|
|||||||
1. Checks Cursor's API for the latest version
|
1. Checks Cursor's API for the latest version
|
||||||
2. Only updates if a new version is available
|
2. Only updates if a new version is available
|
||||||
3. Downloads the AppImage and calculates SHA256 hash
|
3. Downloads the AppImage and calculates SHA256 hash
|
||||||
4. Updates `flake.nix` with new version and hash
|
4. Updates `cursor-release.nix` with the new version and per-architecture hashes
|
||||||
5. Tests the build and commits changes
|
5. Tests the build and commits changes
|
||||||
6. Creates a GitHub release for tracking
|
6. Pushes the update back to the repository
|
||||||
|
|
||||||
### Manual Updates
|
### Manual Updates
|
||||||
The `update-cursor.sh` script provides:
|
The `update-cursor.sh` script provides:
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
# Managed by ./update-cursor.sh
|
||||||
|
#
|
||||||
|
# Notes:
|
||||||
|
# - `sha256` values are Nix base32 hashes (as used by `fetchurl { sha256 = "..."; }`).
|
||||||
|
version = "0.0.0";
|
||||||
|
|
||||||
|
sha256 = {
|
||||||
|
x86_64-linux = "0000000000000000000000000000000000000000000000000000";
|
||||||
|
aarch64-linux = "0000000000000000000000000000000000000000000000000000";
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -7,10 +7,18 @@
|
|||||||
|
|
||||||
outputs = { self, nixpkgs }:
|
outputs = { self, nixpkgs }:
|
||||||
let
|
let
|
||||||
system = "x86_64-linux";
|
lib = nixpkgs.lib;
|
||||||
pkgs = import nixpkgs { inherit system; };
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
|
cursorRelease = import ./cursor-release.nix;
|
||||||
|
|
||||||
buildCursor = { version, url, sha256 }:
|
channelForSystem = {
|
||||||
|
x86_64-linux = "linux-x64";
|
||||||
|
aarch64-linux = "linux-arm64";
|
||||||
|
};
|
||||||
|
|
||||||
|
pkgsFor = system: import nixpkgs { inherit system; };
|
||||||
|
|
||||||
|
buildCursor = pkgs: { version, url, sha256 }:
|
||||||
let
|
let
|
||||||
src = pkgs.fetchurl { inherit url sha256; };
|
src = pkgs.fetchurl { inherit url sha256; };
|
||||||
|
|
||||||
@@ -103,18 +111,22 @@
|
|||||||
};
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
packages.${system} = {
|
packages = lib.genAttrs systems (system:
|
||||||
|
let
|
||||||
|
pkgs = pkgsFor system;
|
||||||
|
version = cursorRelease.version;
|
||||||
|
channel = channelForSystem.${system} or (throw "Unsupported system: ${system}");
|
||||||
|
url = "https://api2.cursor.sh/updates/download/golden/${channel}/cursor/${version}";
|
||||||
|
sha256 = cursorRelease.sha256.${system} or "0000000000000000000000000000000000000000000000000000";
|
||||||
|
in
|
||||||
|
{
|
||||||
default = self.packages.${system}.cursor;
|
default = self.packages.${system}.cursor;
|
||||||
cursor = buildCursor {
|
cursor = buildCursor pkgs { inherit version url sha256; };
|
||||||
version = "2.2.43";
|
});
|
||||||
url = "https://downloads.cursor.com/production/32cfbe848b35d9eb320980195985450f244b303d/linux/x64/Cursor-2.2.43-x86_64.AppImage";
|
|
||||||
sha256 = "1bgifjyscqymbz0srw8np9pc88gwcccic3z4cnydyfskxhnyj0sr"; # Will be updated by GitHub Actions
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Overlay for easy integration into other flakes
|
# Overlay for easy integration into other flakes
|
||||||
overlays.default = final: prev: {
|
overlays.default = final: prev: {
|
||||||
cursor = self.packages.${system}.cursor;
|
cursor = self.packages.${final.system}.cursor;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-3
@@ -63,24 +63,32 @@ fi
|
|||||||
|
|
||||||
# Test 4: Check API connectivity
|
# Test 4: Check API connectivity
|
||||||
echo "4. Testing API connectivity..."
|
echo "4. Testing API connectivity..."
|
||||||
if command -v curl >/dev/null 2>&1 && command -v jq >/dev/null 2>&1; then
|
if command -v curl >/dev/null 2>&1; then
|
||||||
if curl -s --max-time 10 "https://api2.cursor.sh/updates/check/golden/linux-x64-deb/cursor" | jq -r '.version' >/dev/null 2>&1; then
|
if curl -s --max-time 10 -I "https://api2.cursor.sh/updates/download/golden/linux-x64/cursor/latest" >/dev/null 2>&1; then
|
||||||
echo " ✓ Cursor API is accessible"
|
echo " ✓ Cursor API is accessible"
|
||||||
else
|
else
|
||||||
echo " ⚠ Cursor API not accessible (this might be temporary)"
|
echo " ⚠ Cursor API not accessible (this might be temporary)"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo " ⚠ Skipping API test (curl or jq not available)"
|
echo " ⚠ Skipping API test (curl not available)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Test 5: Check current version
|
# Test 5: Check current version
|
||||||
echo "5. Checking current version..."
|
echo "5. Checking current version..."
|
||||||
|
if [[ -f "cursor-release.nix" ]]; then
|
||||||
|
CURRENT_VERSION=$(grep -o 'version = "[^"]*"' cursor-release.nix | head -1 | cut -d'"' -f2)
|
||||||
|
else
|
||||||
CURRENT_VERSION=$(grep -o 'version = "[^"]*"' flake.nix | head -1 | cut -d'"' -f2)
|
CURRENT_VERSION=$(grep -o 'version = "[^"]*"' flake.nix | head -1 | cut -d'"' -f2)
|
||||||
|
fi
|
||||||
echo " Current version: $CURRENT_VERSION"
|
echo " Current version: $CURRENT_VERSION"
|
||||||
|
|
||||||
# Test 6: Check if SHA256 is placeholder
|
# Test 6: Check if SHA256 is placeholder
|
||||||
echo "6. Checking SHA256 hash..."
|
echo "6. Checking SHA256 hash..."
|
||||||
|
if [[ -f "cursor-release.nix" ]]; then
|
||||||
|
CURRENT_SHA256=$(grep -o 'x86_64-linux = "[^"]*"' cursor-release.nix | head -1 | cut -d'"' -f2)
|
||||||
|
else
|
||||||
CURRENT_SHA256=$(grep -o 'sha256 = "[^"]*"' flake.nix | head -1 | cut -d'"' -f2)
|
CURRENT_SHA256=$(grep -o 'sha256 = "[^"]*"' flake.nix | head -1 | cut -d'"' -f2)
|
||||||
|
fi
|
||||||
if [[ "$CURRENT_SHA256" == "0000000000000000000000000000000000000000000000000000" ]]; then
|
if [[ "$CURRENT_SHA256" == "0000000000000000000000000000000000000000000000000000" ]]; then
|
||||||
echo " ⚠ SHA256 is placeholder - needs to be updated"
|
echo " ⚠ SHA256 is placeholder - needs to be updated"
|
||||||
else
|
else
|
||||||
|
|||||||
+67
-38
@@ -2,11 +2,14 @@
|
|||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Script to manually update Cursor version in the flake
|
# Script to manually update Cursor version/hashes used by the flake
|
||||||
# Usage: ./update-cursor.sh [version]
|
# Usage: ./update-cursor.sh [version]
|
||||||
|
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||||
FLAKE_FILE="$SCRIPT_DIR/flake.nix"
|
RELEASE_FILE="$SCRIPT_DIR/cursor-release.nix"
|
||||||
|
|
||||||
|
CHANNEL_FOR_SYSTEM_x86_64_linux="linux-x64"
|
||||||
|
CHANNEL_FOR_SYSTEM_aarch64_linux="linux-arm64"
|
||||||
|
|
||||||
# Function to get latest version from API redirect
|
# Function to get latest version from API redirect
|
||||||
get_latest_version() {
|
get_latest_version() {
|
||||||
@@ -23,56 +26,86 @@ get_latest_version() {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to get current version from flake.nix
|
# Function to get current version from cursor-release.nix
|
||||||
get_current_version() {
|
get_current_version() {
|
||||||
grep -o 'version = "[^"]*"' "$FLAKE_FILE" | head -1 | cut -d'"' -f2
|
grep -o 'version = "[^"]*"' "$RELEASE_FILE" | head -1 | cut -d'"' -f2
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to update flake.nix
|
# Function to compute sha256 for a given system+version
|
||||||
update_flake() {
|
prefetch_sha256() {
|
||||||
local version="$1"
|
local system="$1"
|
||||||
local appimage_url="https://api2.cursor.sh/updates/download/golden/linux-x64/cursor/$version"
|
local version="$2"
|
||||||
|
local channel=""
|
||||||
|
|
||||||
echo "Fetching AppImage from: $appimage_url"
|
case "$system" in
|
||||||
|
x86_64-linux) channel="$CHANNEL_FOR_SYSTEM_x86_64_linux" ;;
|
||||||
|
aarch64-linux) channel="$CHANNEL_FOR_SYSTEM_aarch64_linux" ;;
|
||||||
|
*) echo "Error: Unsupported system: $system" >&2; return 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
# Get the actual download URL by following redirects
|
local url="https://api2.cursor.sh/updates/download/golden/${channel}/cursor/${version}"
|
||||||
local actual_url
|
|
||||||
actual_url=$(curl -s -I "$appimage_url" | grep -i location | cut -d' ' -f2 | tr -d '\r\n')
|
|
||||||
|
|
||||||
if [[ -z "$actual_url" ]]; then
|
if ! command -v nix-prefetch-url >/dev/null 2>&1; then
|
||||||
echo "Error: Could not get actual download URL"
|
echo "Error: nix-prefetch-url not found. Please install Nix (or nix-prefetch-url) and retry." >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Actual download URL: $actual_url"
|
# IMPORTANT: this function is captured by command substitution. Keep stdout as the hash only.
|
||||||
|
echo "Prefetching ($system) from: $url" >&2
|
||||||
|
|
||||||
# Get SHA256 hash
|
local out hash
|
||||||
local sha256
|
out="$(nix-prefetch-url --type sha256 "$url" 2>&1)"
|
||||||
if command -v nix-prefetch-url >/dev/null 2>&1; then
|
echo "$out" >&2
|
||||||
sha256=$(nix-prefetch-url --type sha256 "$actual_url")
|
|
||||||
else
|
# Extract the Nix base32 sha256 hash (52 chars, Nix alphabet).
|
||||||
echo "Warning: nix-prefetch-url not found. You'll need to update the SHA256 manually."
|
hash="$(echo "$out" | grep -Eo '[0-9abcdfghijklmnpqrsvwxyz]{52}' | tail -n1 || true)"
|
||||||
sha256="0000000000000000000000000000000000000000000000000000"
|
if [[ -z "$hash" ]]; then
|
||||||
|
echo "Error: Could not parse sha256 from nix-prefetch-url output for $system" >&2
|
||||||
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "SHA256: $sha256"
|
echo "$hash"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to update cursor-release.nix
|
||||||
|
update_release() {
|
||||||
|
local version="$1"
|
||||||
|
|
||||||
|
echo "Computing hashes for version: $version"
|
||||||
|
|
||||||
|
local sha_x86 sha_aarch64
|
||||||
|
sha_x86="$(prefetch_sha256 x86_64-linux "$version")"
|
||||||
|
sha_aarch64="$(prefetch_sha256 aarch64-linux "$version")"
|
||||||
|
|
||||||
|
echo "x86_64-linux sha256: $sha_x86"
|
||||||
|
echo "aarch64-linux sha256: $sha_aarch64"
|
||||||
|
|
||||||
# Create backup
|
# Create backup
|
||||||
cp "$FLAKE_FILE" "$FLAKE_FILE.backup"
|
cp "$RELEASE_FILE" "$RELEASE_FILE.backup"
|
||||||
|
|
||||||
# Update flake.nix - be more specific to avoid replacing nixpkgs URL
|
cat > "$RELEASE_FILE" <<EOF
|
||||||
sed -i "s/version = \"[^\"]*\"/version = \"$version\"/" "$FLAKE_FILE"
|
{
|
||||||
sed -i "/cursor = buildCursor {/,/};/s|url = \"[^\"]*\"|url = \"$actual_url\"|" "$FLAKE_FILE"
|
# Managed by ./update-cursor.sh
|
||||||
sed -i "/cursor = buildCursor {/,/};/s/sha256 = \"[^\"]*\"/sha256 = \"$sha256\"/" "$FLAKE_FILE"
|
#
|
||||||
|
# Notes:
|
||||||
|
# - \`sha256\` values are Nix base32 hashes (as used by \`fetchurl { sha256 = "..."; }\`).
|
||||||
|
version = "$version";
|
||||||
|
|
||||||
echo "Updated flake.nix with version $version"
|
sha256 = {
|
||||||
|
x86_64-linux = "$sha_x86";
|
||||||
|
aarch64-linux = "$sha_aarch64";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "Updated cursor-release.nix with version $version"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Function to test the flake
|
# Function to test the flake
|
||||||
test_flake() {
|
test_flake() {
|
||||||
echo "Testing flake..."
|
echo "Testing flake..."
|
||||||
if command -v nix >/dev/null 2>&1; then
|
if command -v nix >/dev/null 2>&1; then
|
||||||
nix flake check
|
nix flake check --no-build
|
||||||
echo "Flake check passed!"
|
echo "Flake check passed!"
|
||||||
else
|
else
|
||||||
echo "Warning: nix command not found. Skipping flake check."
|
echo "Warning: nix command not found. Skipping flake check."
|
||||||
@@ -110,9 +143,6 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Update needed: $current_version -> $target_version"
|
echo "Update needed: $current_version -> $target_version"
|
||||||
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
|
|
||||||
echo "CURSOR_VERSION_INFO=updated:$current_version:$target_version" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Check if running in CI/GitHub Actions (auto-confirm)
|
# Check if running in CI/GitHub Actions (auto-confirm)
|
||||||
if [[ -n "${CI:-}" ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; then
|
if [[ -n "${CI:-}" ]] || [[ -n "${GITHUB_ACTIONS:-}" ]]; then
|
||||||
@@ -124,14 +154,14 @@ main() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
update_flake "$target_version"
|
update_release "$target_version"
|
||||||
test_flake
|
test_flake
|
||||||
echo "Update completed successfully!"
|
echo "Update completed successfully!"
|
||||||
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
|
if [[ -n "${GITHUB_OUTPUT:-}" ]]; then
|
||||||
echo "CURSOR_VERSION_INFO=completed:$current_version:$target_version" >> "$GITHUB_OUTPUT"
|
echo "CURSOR_VERSION_INFO=completed:$current_version:$target_version" >> "$GITHUB_OUTPUT"
|
||||||
fi
|
fi
|
||||||
echo "You can now commit the changes:"
|
echo "You can now commit the changes:"
|
||||||
echo " git add flake.nix"
|
echo " git add flake.nix cursor-release.nix"
|
||||||
echo " git commit -m \"Update Cursor to version $target_version\""
|
echo " git commit -m \"Update Cursor to version $target_version\""
|
||||||
else
|
else
|
||||||
echo "Update cancelled."
|
echo "Update cancelled."
|
||||||
@@ -146,9 +176,8 @@ check_dependencies() {
|
|||||||
if ! command -v curl >/dev/null 2>&1; then
|
if ! command -v curl >/dev/null 2>&1; then
|
||||||
missing_deps+=("curl")
|
missing_deps+=("curl")
|
||||||
fi
|
fi
|
||||||
|
if [[ ! -f "$RELEASE_FILE" ]]; then
|
||||||
if ! command -v jq >/dev/null 2>&1; then
|
missing_deps+=("cursor-release.nix (missing file)")
|
||||||
missing_deps+=("jq")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#missing_deps[@]} -gt 0 ]]; then
|
if [[ ${#missing_deps[@]} -gt 0 ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user