Remove cursor-release.nix and integrate its content into flake.nix for better management of version and architecture-specific sources.
Update Cursor Version / update-cursor (push) Failing after 3m22s

This commit is contained in:
2026-01-11 21:34:04 -04:00
parent 2cc7bde1e1
commit 839fdd2048
4 changed files with 81 additions and 60 deletions
+2 -2
View File
@@ -75,11 +75,11 @@ To update to a specific version:
## How It Works ## How It Works
### Automatic Updates ### Automatic Updates
The CI workflow in `.github/workflows/update-cursor.yml` runs daily and: In CI (or manually), `./update-cursor.sh` can be run 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 `cursor-release.nix` with the new version and **per-architecture hashes** (`x86_64-linux` + `aarch64-linux`) 4. Updates the managed block in `flake.nix` with the new version and **per-architecture sources** (`x86_64-linux` + `aarch64-linux`)
5. Tests the build and commits changes 5. Tests the build and commits changes
6. Pushes the update back to the repository 6. Pushes the update back to the repository
-17
View File
@@ -1,17 +0,0 @@
{
# Managed by ./update-cursor.sh
#
# Notes:
# - `sha256` values are Nix base32 hashes (as used by `fetchurl { sha256 = "..."; }`).
version = "2.3.34";
url = {
x86_64-linux = "https://downloads.cursor.com/production/643ba67cd252e2888e296dd0cf34a0c5d7625b96/linux/x64/Cursor-2.3.34-x86_64.AppImage";
aarch64-linux = "https://downloads.cursor.com/production/643ba67cd252e2888e296dd0cf34a0c5d7625b96/linux/arm64/Cursor-2.3.34-aarch64.AppImage";
};
sha256 = {
x86_64-linux = "1sn3fzby9nn388azyp73fqsmnq51n9z42q208prn3l2zw44brjv6";
aarch64-linux = "1msdsv0h53slmlnsckrl32g9pnqxx44039yky59h78pgfwy5kjgg";
};
}
+19 -16
View File
@@ -9,18 +9,30 @@
let let
lib = nixpkgs.lib; lib = nixpkgs.lib;
systems = [ "x86_64-linux" "aarch64-linux" ]; systems = [ "x86_64-linux" "aarch64-linux" ];
cursorRelease = import ./cursor-release.nix;
channelForSystem = { # BEGIN managed by ./update-cursor.sh
x86_64-linux = "linux-x64"; version = "2.3.34";
aarch64-linux = "linux-arm64"; sources = {
x86_64-linux = {
url = "https://downloads.cursor.com/production/643ba67cd252e2888e296dd0cf34a0c5d7625b96/linux/x64/Cursor-2.3.34-x86_64.AppImage";
sha256 = "1sn3fzby9nn388azyp73fqsmnq51n9z42q208prn3l2zw44brjv6";
};
aarch64-linux = {
url = "https://downloads.cursor.com/production/643ba67cd252e2888e296dd0cf34a0c5d7625b96/linux/arm64/Cursor-2.3.34-aarch64.AppImage";
sha256 = "1msdsv0h53slmlnsckrl32g9pnqxx44039yky59h78pgfwy5kjgg";
};
}; };
# END managed by ./update-cursor.sh
pkgsFor = system: import nixpkgs { inherit system; }; pkgsFor = system: import nixpkgs { inherit system; };
buildCursor = pkgs: { version, url, sha256 }: buildCursor = { pkgs, system }:
let let
src = pkgs.fetchurl { inherit url sha256; }; source = sources.${system} or (throw "Unsupported system: ${system}");
src = pkgs.fetchurl {
url = source.url;
sha256 = source.sha256;
};
# Extract the AppImage to get access to the icon and desktop file # Extract the AppImage to get access to the icon and desktop file
appimageContents = pkgs.appimageTools.extract { appimageContents = pkgs.appimageTools.extract {
@@ -114,19 +126,10 @@
packages = lib.genAttrs systems (system: packages = lib.genAttrs systems (system:
let let
pkgs = pkgsFor system; pkgs = pkgsFor system;
version = cursorRelease.version;
channel = channelForSystem.${system} or (throw "Unsupported system: ${system}");
# Prefer the stable resolved downloads.cursor.com URL stored by ./update-cursor.sh.
# Fallback to the API URL for older cursor-release.nix files.
url =
if cursorRelease ? url && cursorRelease.url ? ${system}
then cursorRelease.url.${system}
else "https://api2.cursor.sh/updates/download/golden/${channel}/cursor/${version}";
sha256 = cursorRelease.sha256.${system} or "0000000000000000000000000000000000000000000000000000";
in in
{ {
default = self.packages.${system}.cursor; default = self.packages.${system}.cursor;
cursor = buildCursor pkgs { inherit version url sha256; }; cursor = buildCursor { inherit pkgs system; };
}); });
# Overlay for easy integration into other flakes # Overlay for easy integration into other flakes
+60 -25
View File
@@ -10,7 +10,10 @@ set -euo pipefail
# ./update-cursor.sh 2.2 # follow a major.minor pointer only # ./update-cursor.sh 2.2 # follow a major.minor pointer only
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
RELEASE_FILE="$SCRIPT_DIR/cursor-release.nix" FLAKE_FILE="$SCRIPT_DIR/flake.nix"
MANAGED_BEGIN="# BEGIN managed by ./update-cursor.sh"
MANAGED_END="# END managed by ./update-cursor.sh"
INDENT=" "
CHANNEL_FOR_SYSTEM_x86_64_linux="linux-x64" CHANNEL_FOR_SYSTEM_x86_64_linux="linux-x64"
CHANNEL_FOR_SYSTEM_aarch64_linux="linux-arm64" CHANNEL_FOR_SYSTEM_aarch64_linux="linux-arm64"
@@ -108,9 +111,13 @@ is_pointer() {
[[ "${1:-}" == "latest" || "${1:-}" =~ ^[0-9]+\.[0-9]+$ ]] [[ "${1:-}" == "latest" || "${1:-}" =~ ^[0-9]+\.[0-9]+$ ]]
} }
# Function to get current version from cursor-release.nix # Function to get current version from flake.nix managed block
get_current_version() { get_current_version() {
grep -o 'version = "[^"]*"' "$RELEASE_FILE" | head -1 | cut -d'"' -f2 awk -v begin="$MANAGED_BEGIN" -v end="$MANAGED_END" '
$0 ~ begin {inblock=1; next}
$0 ~ end {inblock=0}
inblock && match($0, /version = "([^"]+)";/, m) { print m[1]; exit }
' "$FLAKE_FILE"
} }
# Derive major.minor track from a full version (e.g. 2.2.43 -> 2.2). # Derive major.minor track from a full version (e.g. 2.2.43 -> 2.2).
@@ -159,7 +166,7 @@ prefetch_sha256() {
echo "$hash" echo "$hash"
} }
# Function to update cursor-release.nix # Update flake.nix managed block with a new version + per-system urls/hashes
update_release() { update_release() {
local version="$1" local version="$1"
@@ -175,30 +182,58 @@ update_release() {
echo "x86_64-linux sha256: $sha_x86" echo "x86_64-linux sha256: $sha_x86"
echo "aarch64-linux sha256: $sha_aarch64" echo "aarch64-linux sha256: $sha_aarch64"
if ! grep -qF "$MANAGED_BEGIN" "$FLAKE_FILE" || ! grep -qF "$MANAGED_END" "$FLAKE_FILE"; then
echo "Error: Could not find managed block markers in $FLAKE_FILE" >&2
echo "Expected lines containing:" >&2
echo " $MANAGED_BEGIN" >&2
echo " $MANAGED_END" >&2
return 1
fi
# Create backup # Create backup
cp "$RELEASE_FILE" "$RELEASE_FILE.backup" cp "$FLAKE_FILE" "$FLAKE_FILE.backup"
cat > "$RELEASE_FILE" <<EOF local tmp_file
{ tmp_file="$(mktemp -t cursor-flake-update-XXXXXX)"
# Managed by ./update-cursor.sh
#
# Notes:
# - \`sha256\` values are Nix base32 hashes (as used by \`fetchurl { sha256 = "..."; }\`).
version = "$version";
url = { local inblock=0
x86_64-linux = "$url_x86"; while IFS= read -r line; do
aarch64-linux = "$url_aarch64"; if [[ "$inblock" -eq 0 && "$line" == *"$MANAGED_BEGIN"* ]]; then
}; printf '%s\n' "$line" >> "$tmp_file"
sha256 = { cat >> "$tmp_file" <<EOF
x86_64-linux = "$sha_x86"; ${INDENT}version = "$version";
aarch64-linux = "$sha_aarch64"; ${INDENT}sources = {
}; ${INDENT} x86_64-linux = {
} ${INDENT} url = "$url_x86";
${INDENT} sha256 = "$sha_x86";
${INDENT} };
${INDENT} aarch64-linux = {
${INDENT} url = "$url_aarch64";
${INDENT} sha256 = "$sha_aarch64";
${INDENT} };
${INDENT}};
EOF EOF
echo "Updated cursor-release.nix with version $version" inblock=1
continue
fi
if [[ "$inblock" -eq 1 && "$line" == *"$MANAGED_END"* ]]; then
printf '%s\n' "$line" >> "$tmp_file"
inblock=0
continue
fi
if [[ "$inblock" -eq 1 ]]; then
continue
fi
printf '%s\n' "$line" >> "$tmp_file"
done < "$FLAKE_FILE"
mv "$tmp_file" "$FLAKE_FILE"
echo "Updated flake.nix managed block with version $version"
} }
# Function to test the flake # Function to test the flake
@@ -289,7 +324,7 @@ main() {
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 cursor-release.nix" echo " git add flake.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."
@@ -304,8 +339,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 [[ ! -f "$FLAKE_FILE" ]]; then
missing_deps+=("cursor-release.nix (missing file)") missing_deps+=("flake.nix (missing file)")
fi fi
if [[ ${#missing_deps[@]} -gt 0 ]]; then if [[ ${#missing_deps[@]} -gt 0 ]]; then