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
+60 -25
View File
@@ -10,7 +10,10 @@ set -euo pipefail
# ./update-cursor.sh 2.2 # follow a major.minor pointer only
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_aarch64_linux="linux-arm64"
@@ -108,9 +111,13 @@ is_pointer() {
[[ "${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() {
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).
@@ -159,7 +166,7 @@ prefetch_sha256() {
echo "$hash"
}
# Function to update cursor-release.nix
# Update flake.nix managed block with a new version + per-system urls/hashes
update_release() {
local version="$1"
@@ -175,30 +182,58 @@ update_release() {
echo "x86_64-linux sha256: $sha_x86"
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
cp "$RELEASE_FILE" "$RELEASE_FILE.backup"
cp "$FLAKE_FILE" "$FLAKE_FILE.backup"
cat > "$RELEASE_FILE" <<EOF
{
# Managed by ./update-cursor.sh
#
# Notes:
# - \`sha256\` values are Nix base32 hashes (as used by \`fetchurl { sha256 = "..."; }\`).
version = "$version";
local tmp_file
tmp_file="$(mktemp -t cursor-flake-update-XXXXXX)"
url = {
x86_64-linux = "$url_x86";
aarch64-linux = "$url_aarch64";
};
local inblock=0
while IFS= read -r line; do
if [[ "$inblock" -eq 0 && "$line" == *"$MANAGED_BEGIN"* ]]; then
printf '%s\n' "$line" >> "$tmp_file"
sha256 = {
x86_64-linux = "$sha_x86";
aarch64-linux = "$sha_aarch64";
};
}
cat >> "$tmp_file" <<EOF
${INDENT}version = "$version";
${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
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
@@ -289,7 +324,7 @@ main() {
echo "CURSOR_VERSION_INFO=completed:$current_version:$target_version" >> "$GITHUB_OUTPUT"
fi
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\""
else
echo "Update cancelled."
@@ -304,8 +339,8 @@ check_dependencies() {
if ! command -v curl >/dev/null 2>&1; then
missing_deps+=("curl")
fi
if [[ ! -f "$RELEASE_FILE" ]]; then
missing_deps+=("cursor-release.nix (missing file)")
if [[ ! -f "$FLAKE_FILE" ]]; then
missing_deps+=("flake.nix (missing file)")
fi
if [[ ${#missing_deps[@]} -gt 0 ]]; then