{ lib, stdenv, callPackage, vscode-generic, fetchurl, appimageTools, undmg, commandLineArgs ? "", useVSCodeRipgrep ? stdenv.hostPlatform.isDarwin, }: let inherit (stdenv) hostPlatform; finalCommandLineArgs = "--update=false " + commandLineArgs; sources = { x86_64-linux = fetchurl { url = "https://downloads.cursor.com/production/faa03b17cce93e8a80b7d62d57f5eda6bb6ab9fa/linux/x64/Cursor-1.2.2-x86_64.AppImage"; hash = "sha256-mQr1QMw4wP+kHvE9RWPkCKtHObbr0jpyOxNw3LfTPfc="; }; aarch64-linux = fetchurl { url = "https://downloads.cursor.com/production/faa03b17cce93e8a80b7d62d57f5eda6bb6ab9fa/linux/arm64/Cursor-1.2.2-aarch64.AppImage"; hash = "sha256-EGvm/VW+NDTmOB1o2j3dpq4ckWbroFWEbF9Pezr8SZQ="; }; x86_64-darwin = fetchurl { url = "https://downloads.cursor.com/production/faa03b17cce93e8a80b7d62d57f5eda6bb6ab9fa/darwin/x64/Cursor-darwin-x64.dmg"; hash = "sha256-IDJklB8wMfrPpc2SO02iVBBE9d7fLN7JotVpPyCQkyE="; }; aarch64-darwin = fetchurl { url = "https://downloads.cursor.com/production/faa03b17cce93e8a80b7d62d57f5eda6bb6ab9fa/darwin/arm64/Cursor-darwin-arm64.dmg"; hash = "sha256-GxiNf58Kf5/l01eBhXRWMLMxAnj1txDQwSe5ei6nTgg="; }; }; source = sources.${hostPlatform.system}; in (callPackage vscode-generic rec { inherit useVSCodeRipgrep; commandLineArgs = finalCommandLineArgs; version = "1.2.2"; pname = "cursor"; # You can find the current VSCode version in the About dialog: # workbench.action.showAboutDialog (Help: About) vscodeVersion = "1.96.2"; executableName = "cursor"; longName = "Cursor"; shortName = "cursor"; libraryName = "cursor"; iconName = "cursor"; src = if hostPlatform.isLinux then appimageTools.extract { inherit pname version; src = source; } else source; sourceRoot = if hostPlatform.isLinux then "${pname}-${version}-extracted/usr/share/cursor" else "Cursor.app"; tests = { }; updateScript = ./update.sh; # Editing the `cursor` binary within the app bundle causes the bundle's signature # to be invalidated, which prevents launching starting with macOS Ventura, because Cursor is notarized. # See https://eclecticlight.co/2022/06/17/app-security-changes-coming-in-ventura/ for more information. dontFixup = stdenv.hostPlatform.isDarwin; # Cursor has no wrapper script. patchVSCodePath = false; meta = { description = "AI-powered code editor built on vscode"; homepage = "https://cursor.com"; changelog = "https://cursor.com/changelog"; license = lib.licenses.unfree; sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; maintainers = with lib.maintainers; [ aspauldingcode prince213 ]; platforms = [ "aarch64-linux" "x86_64-linux" ] ++ lib.platforms.darwin; mainProgram = "cursor"; }; }).overrideAttrs (oldAttrs: { nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ]) ++ lib.optionals hostPlatform.isDarwin [ undmg ]; preInstall = (oldAttrs.preInstall or "") + lib.optionalString hostPlatform.isLinux '' mkdir -p bin ln -s ../cursor bin/cursor ''; passthru = (oldAttrs.passthru or { }) // { inherit sources; }; })