Created
June 2, 2024 18:58
-
-
Save lukalotl/fcbf3216ad13b8303ab0947af0d5abd5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {pkgs, ...}: let | |
| pname = "cursor"; | |
| version = "0.32.2"; | |
| src = pkgs.fetchurl { | |
| # this will break if the version is updated. | |
| # unfortunately, i couldn't seem to find a url that | |
| # points to a specific version. | |
| # alternatively, download the appimage manually and | |
| # include it via src = ./cursor.AppImage, instead of fetchurl | |
| url = "https://download.cursor.sh/linux/appImage/x64"; | |
| hash = "sha256-q2aQWMUp6Ay5kThrH/QSAFozz8IRqzySOcsM9Cy/vKo="; | |
| }; | |
| appimageContents = pkgs.appimageTools.extract {inherit pname version src;}; | |
| in | |
| with pkgs; | |
| appimageTools.wrapType2 { | |
| inherit pname version src; | |
| extraInstallCommands = '' | |
| install -m 444 -D ${appimageContents}/${pname}.desktop -t $out/share/applications | |
| substituteInPlace $out/share/applications/${pname}.desktop \ | |
| --replace 'Exec=AppRun' 'Exec=${pname}' | |
| cp -r ${appimageContents}/usr/share/icons $out/share | |
| # unless linked, the binary is placed in $out/bin/cursor-someVersion | |
| ln -s $out/bin/${pname}-${version} $out/bin/${pname} | |
| ''; | |
| extraBwrapArgs = [ | |
| "--bind-try /etc/nixos/ /etc/nixos/" | |
| ]; | |
| # vscode likes to kill the parent so that the | |
| # gui application isn't attached to the terminal session | |
| dieWithParent = false; | |
| extraPkgs = pkgs: [ | |
| unzip | |
| autoPatchelfHook | |
| asar | |
| # override doesn't preserve splicing https://github.com/NixOS/nixpkgs/issues/132651 | |
| (buildPackages.wrapGAppsHook.override {inherit (buildPackages) makeWrapper;}) | |
| ]; | |
| } |
by the way this is probably depricated now.
In addition, I've added support for cursor for aarch64-linux, and both darwin architectures to mainline nixpkgs, pending merge PR: NixOS/nixpkgs#374944
Future readers might find this useful. I was using the code-cursor package, but I wanted to use the latest unstable version only for code-cursor.
I created a /etc/nixos/flake.nix file:
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs, nixpkgs-unstable, ... }@inputs: {
nixosConfigurations.nixos = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [ ./configuration.nix ];
specialArgs = { inherit inputs; };
};
};
}Then I updated my /etc/nixos/configuration.nix:
{ config, pkgs, inputs, ... }:
let
unstable = import inputs.nixpkgs-unstable {
system = "x86_64-linux";
config.allowUnfree = true;
};
in {
environment.systemPackages = with pkgs; [
git # Normal packages use 24.11
unstable.code-cursor # Only code-cursor uses unstable version
];
# ...other settings
system.stateVersion = "24.11";
}Then I run this ~/update.sh script to update:
#!/usr/bin/env bash
set -euo pipefail
echo "π Starting system update..."
# Clean up old generations
sudo nix-collect-garbage --delete-older-than 14d
# Update flake inputs with explicit directory context
echo "π Updating flake inputs..."
sudo bash -c "cd /etc/nixos && nix flake update"
# Rebuild system
echo "π¨ Rebuilding system..."
sudo nixos-rebuild boot --flake "/etc/nixos#nixos" # Change 'nixos' to your hostname
# Update Flatpak
echo "π¦ Updating Flatpak..."
flatpak update -y
echo "β
Update complete!"
notify-send "System Updated" "All updates applied successfully"
by the way this is probably depricated now.
In addition, I've added support for cursor for aarch64-linux, and both darwin architectures to mainline nixpkgs, pending merge PR: NixOS/nixpkgs#374944
This pr has merged and code-cursor package now supports macOS and arch64 linux.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for the quick response @mwmdev, it's much appreciated!
I'm currently using unstable via flakes:

π€