136 lines
4.1 KiB
Markdown
136 lines
4.1 KiB
Markdown
# Self-Updating Cursor Flake
|
||
|
||
A Nix flake that provides the Cursor code editor with automatic daily updates via CI (GitHub Actions-compatible workflows, e.g. GitHub Actions or Gitea Actions).
|
||
|
||
This fork includes **native `aarch64-linux` (linux-arm64) support** in addition to `x86_64-linux`.
|
||
|
||
## Features
|
||
|
||
- 🚀 **Self-updating**: Automatically checks for new Cursor versions daily
|
||
- 🔧 **Manual updates**: Local script for immediate updates
|
||
- 🛡️ **Robust**: Proper error handling and fallbacks
|
||
- 📦 **AppImage-based**: Uses Cursor's official AppImage for maximum compatibility
|
||
- 🎯 **Linux x86_64 + aarch64**: Supports both AMD64 and ARM64 (aarch64) Linux
|
||
|
||
## Quick Start
|
||
|
||
### Method 1: Direct Installation
|
||
```bash
|
||
# Install Cursor directly
|
||
nix profile install git+https://git.chiasson.cloud/Olivier/cursor-nixos-flake
|
||
|
||
# Run Cursor
|
||
cursor --version
|
||
```
|
||
|
||
### Method 2: Add to Your Flake
|
||
Add to your `flake.nix` inputs:
|
||
```nix
|
||
inputs.cursor.url = "git+https://git.chiasson.cloud/Olivier/cursor-nixos-flake";
|
||
```
|
||
|
||
Then use in your configuration:
|
||
```nix
|
||
# For NixOS system configuration
|
||
environment.systemPackages = with pkgs; [
|
||
cursor.packages.${pkgs.system}.cursor
|
||
];
|
||
|
||
# For home-manager
|
||
home.packages = with pkgs; [
|
||
cursor.packages.${pkgs.system}.cursor
|
||
];
|
||
|
||
# For devShell
|
||
devShells.default = pkgs.mkShell {
|
||
packages = with pkgs; [
|
||
cursor.packages.${pkgs.system}.cursor
|
||
];
|
||
};
|
||
```
|
||
|
||
### Method 3: Temporary Run
|
||
```bash
|
||
# Run without installing
|
||
nix run git+https://git.chiasson.cloud/Olivier/cursor-nixos-flake
|
||
|
||
# Build and run
|
||
nix build git+https://git.chiasson.cloud/Olivier/cursor-nixos-flake
|
||
./result/bin/cursor
|
||
```
|
||
|
||
## Manual Update
|
||
|
||
To manually update Cursor to the latest version:
|
||
|
||
```bash
|
||
./update-cursor.sh
|
||
```
|
||
To update to a specific version:
|
||
|
||
```bash
|
||
./update-cursor.sh 1.8.0
|
||
```
|
||
|
||
## How It Works
|
||
|
||
### Automatic Updates
|
||
In CI (or manually), `./update-cursor.sh` can be run daily and:
|
||
1. Checks Cursor's API for the latest version
|
||
2. Only updates if a new version is available
|
||
3. Downloads the AppImage and calculates SHA256 hash
|
||
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
|
||
6. Pushes the update back to the repository
|
||
|
||
### Manual Updates
|
||
The `update-cursor.sh` script provides:
|
||
- Version checking and comparison
|
||
- Safe updates with backups
|
||
- Build validation
|
||
- Interactive confirmation prompts
|
||
|
||
## API Endpoints
|
||
|
||
- **x86_64 AppImage Download**: `https://api2.cursor.sh/updates/download/golden/linux-x64/cursor/{version}`
|
||
- **aarch64 AppImage Download**: `https://api2.cursor.sh/updates/download/golden/linux-arm64/cursor/{version}`
|
||
|
||
### Version pointers / "channels"
|
||
|
||
Cursor exposes a few redirect-style pointers that may not always move in lockstep:
|
||
|
||
- **`.../cursor/latest`**: “promoted” latest build for that channel. This can lag a new release during phased rollout / promotion.
|
||
- **`.../cursor/{major.minor}` (e.g. `.../cursor/2.2`)**: latest patch within that major.minor line. This can point to a newer build earlier than `latest`.
|
||
|
||
Concrete example (this has happened in practice):
|
||
|
||
- `.../cursor/latest` redirects to **`Cursor-2.2.43-...AppImage`**
|
||
- `.../cursor/2.2` redirects to **`Cursor-2.2.44-...AppImage`**
|
||
|
||
In that situation, **`latest` is behind**. This flake’s updater checks both and will choose **2.2.44**.
|
||
|
||
This flake’s `update-cursor.sh` default (**auto**) strategy:
|
||
|
||
- **Checks multiple pointers**: `latest`, the current installed major.minor (e.g. `2.2`), and (if different) `latest`’s own major.minor (e.g. `2.3`).
|
||
- **Picks the highest semver**: so it won’t stick to an old minor, but it also won’t miss patch releases when `latest` lags.
|
||
|
||
## Testing
|
||
|
||
```bash
|
||
# Test flake syntax
|
||
nix flake check
|
||
|
||
# Test building
|
||
nix build '.#cursor' --dry-run
|
||
```
|
||
|
||
## Development
|
||
|
||
### Customization
|
||
- **Update frequency**: Modify cron schedule in `.github/workflows/update-cursor.yml`
|
||
- **API endpoints**: Update URLs in workflow and update script
|
||
- **Build options**: Modify the `buildCursor` function in `flake.nix`
|
||
|
||
## License
|
||
|
||
MIT License - see [LICENSE](LICENSE) file for details. |