f77f5b1131
- Simplified flake.nix to focus only on packaging Cursor - Removed system configuration files (archived locally) - Updated to clean, reusable flake structure - Added simple update-cursor.sh script - Updated documentation for new structure This migration makes the flake purely focused on providing the Cursor package.
181 lines
4.8 KiB
Markdown
181 lines
4.8 KiB
Markdown
# Cursor NixOS Flake
|
|
|
|
A clean, simple NixOS flake for packaging the [Cursor](https://cursor.sh/) AI-powered code editor.
|
|
|
|
## 📦 What This Flake Provides
|
|
|
|
This flake packages Cursor as a Nix package that can be easily integrated into any NixOS system or used standalone.
|
|
|
|
**Packages:**
|
|
- `packages.x86_64-linux.cursor` - The Cursor editor
|
|
- `packages.x86_64-linux.default` - Same as cursor (default package)
|
|
|
|
## 🚀 Quick Start
|
|
|
|
### Using in Your NixOS Configuration
|
|
|
|
Add this flake as an input to your main system flake:
|
|
|
|
```nix
|
|
{
|
|
inputs = {
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
|
cursor-flake = {
|
|
url = "path:/path/to/cursor-flake"; # Update this path
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
# ... other inputs
|
|
};
|
|
|
|
outputs = { nixpkgs, cursor-flake, ... }: {
|
|
nixosConfigurations.your-hostname = nixpkgs.lib.nixosSystem {
|
|
# ...
|
|
modules = [
|
|
./configuration.nix
|
|
{
|
|
# Add Cursor to your system packages
|
|
environment.systemPackages = with pkgs; [
|
|
cursor-flake.packages.x86_64-linux.cursor
|
|
# ... other packages
|
|
];
|
|
}
|
|
# Or in home-manager:
|
|
{
|
|
home-manager.users.your-username = { pkgs, ... }: {
|
|
home.packages = [
|
|
cursor-flake.packages.x86_64-linux.cursor
|
|
# ... other packages
|
|
];
|
|
};
|
|
}
|
|
];
|
|
};
|
|
};
|
|
}
|
|
```
|
|
|
|
### Standalone Usage
|
|
|
|
You can also build and run Cursor directly from this flake:
|
|
|
|
```bash
|
|
# Build the package
|
|
nix build .#cursor
|
|
|
|
# Run Cursor
|
|
./result/bin/cursor
|
|
|
|
# Or run directly without building
|
|
nix run .#cursor
|
|
```
|
|
|
|
## 🔄 Updating Cursor
|
|
|
|
When a new version of Cursor is released, use the included update script:
|
|
|
|
### Method 1: Automatic with URL
|
|
```bash
|
|
./update-cursor.sh "https://downloads.cursor.com/production/[hash]/linux/x64/Cursor-1.6.0-x86_64.AppImage"
|
|
```
|
|
|
|
### Method 2: Interactive
|
|
```bash
|
|
./update-cursor.sh
|
|
# Follow the prompts to enter version or URL
|
|
```
|
|
|
|
### Method 3: Version number
|
|
```bash
|
|
./update-cursor.sh "1.6.0"
|
|
# Script will prompt for the full download URL
|
|
```
|
|
|
|
The script will automatically:
|
|
- ✅ Update the version in `flake.nix`
|
|
- ✅ Update the download URL
|
|
- ✅ Fetch and update the SHA256 hash
|
|
- ✅ Test that the package builds correctly
|
|
- ✅ Verify the version is correct
|
|
|
|
## 📁 Repository Structure
|
|
|
|
```
|
|
cursor-flake/
|
|
├── flake.nix # Main flake configuration (package-only)
|
|
├── flake.lock # Flake lock file
|
|
├── update-cursor.sh # Update script for new versions
|
|
├── README.md # This file
|
|
├── LICENSE # MIT License
|
|
└── archive-old-system-configs/ # Archived old system configs
|
|
├── configuration.nix # (archived - was for full system setup)
|
|
├── home.nix # (archived - was for home-manager)
|
|
└── ... # (other archived files)
|
|
```
|
|
|
|
## 🔧 Development
|
|
|
|
### Testing Changes
|
|
|
|
```bash
|
|
# Test that the package builds
|
|
nix build .#cursor
|
|
|
|
# Test that it runs
|
|
./result/bin/cursor --version
|
|
|
|
# Clean build (removes cached results)
|
|
nix build .#cursor --rebuild
|
|
```
|
|
|
|
### Manual Updates
|
|
|
|
If you prefer to update manually:
|
|
|
|
1. Get the new AppImage URL from [cursor.sh](https://cursor.sh)
|
|
2. Update version and URL in `flake.nix`
|
|
3. Get the new hash:
|
|
```bash
|
|
nix-prefetch-url "https://downloads.cursor.com/production/[hash]/linux/x64/Cursor-X.Y.Z-x86_64.AppImage"
|
|
```
|
|
4. Update the hash in `flake.nix`
|
|
5. Test: `nix build .#cursor`
|
|
|
|
## 🏗️ Architecture
|
|
|
|
This flake uses `appimageTools.wrapType2` to properly package the Cursor AppImage with all necessary dependencies. The wrapper:
|
|
|
|
- Bundles required system libraries
|
|
- Sets up proper environment variables
|
|
- Disables Cursor's built-in updater (managed by Nix instead)
|
|
- Creates temporary directories to avoid permission issues
|
|
- Provides a clean `cursor` command
|
|
|
|
## 🆚 Migration from Complex Structure
|
|
|
|
This flake was simplified from a previous version that included full NixOS system configurations. The old structure has been archived in `archive-old-system-configs/` for reference.
|
|
|
|
**Benefits of the new structure:**
|
|
- ✅ **Focused**: Just packages Cursor, nothing else
|
|
- ✅ **Reusable**: Easy to integrate into any NixOS system
|
|
- ✅ **Maintainable**: No complex system configurations to maintain
|
|
- ✅ **Safe**: No risk of breaking your system during updates
|
|
- ✅ **Consistent**: Matches the pattern of other package flakes
|
|
|
|
## 📜 License
|
|
|
|
MIT License - see [LICENSE](LICENSE) file.
|
|
|
|
## 🤝 Contributing
|
|
|
|
Issues and pull requests are welcome! Please test any changes by running:
|
|
|
|
```bash
|
|
nix build .#cursor
|
|
./result/bin/cursor --version
|
|
```
|
|
|
|
## 🔗 Related
|
|
|
|
- [Cursor Official Website](https://cursor.sh/)
|
|
- [NixOS Documentation](https://nixos.org/manual/nixos/stable/)
|
|
- [Nix Flakes Documentation](https://nixos.wiki/wiki/Flakes) |