1{
2 lib,
3 stdenv,
4 callPackage,
5 vscode-generic,
6 fetchurl,
7 appimageTools,
8 undmg,
9 commandLineArgs ? "",
10 useVSCodeRipgrep ? stdenv.hostPlatform.isDarwin,
11}:
12
13let
14 inherit (stdenv) hostPlatform;
15 finalCommandLineArgs = "--update=false " + commandLineArgs;
16
17 sources = {
18 x86_64-linux = fetchurl {
19 url = "https://downloads.cursor.com/production/3ccce8f55d8cca49f6d28b491a844c699b8719a3/linux/x64/Cursor-1.6.45-x86_64.AppImage";
20 hash = "sha256-MlrevU26gD6hpZbqbdKQwnzJbm5y9SVSb3d0BGnHtpc=";
21 };
22 aarch64-linux = fetchurl {
23 url = "https://downloads.cursor.com/production/3ccce8f55d8cca49f6d28b491a844c699b8719a3/linux/arm64/Cursor-1.6.45-aarch64.AppImage";
24 hash = "sha256-eFHYRwVXhWB3zCnJFYodIxjR2ewP8ETgwyjBdB86oTk=";
25 };
26 x86_64-darwin = fetchurl {
27 url = "https://downloads.cursor.com/production/3ccce8f55d8cca49f6d28b491a844c699b8719a3/darwin/x64/Cursor-darwin-x64.dmg";
28 hash = "sha256-UGmMX9Wr69i2EqQSLkj9/ROs8HpLtc/x0IYDJdzvD6U=";
29 };
30 aarch64-darwin = fetchurl {
31 url = "https://downloads.cursor.com/production/3ccce8f55d8cca49f6d28b491a844c699b8719a3/darwin/arm64/Cursor-darwin-arm64.dmg";
32 hash = "sha256-lcuJiAgHXPEUZHNeanBq10znXKFKJ6yrluuZjdaQbyA=";
33 };
34 };
35
36 source = sources.${hostPlatform.system};
37in
38(callPackage vscode-generic rec {
39 inherit useVSCodeRipgrep;
40 commandLineArgs = finalCommandLineArgs;
41
42 version = "1.6.45";
43 pname = "cursor";
44
45 # You can find the current VSCode version in the About dialog:
46 # workbench.action.showAboutDialog (Help: About)
47 vscodeVersion = "1.99.3";
48
49 executableName = "cursor";
50 longName = "Cursor";
51 shortName = "cursor";
52 libraryName = "cursor";
53 iconName = "cursor";
54
55 src =
56 if hostPlatform.isLinux then
57 appimageTools.extract {
58 inherit pname version;
59 src = source;
60 }
61 else
62 source;
63
64 sourceRoot =
65 if hostPlatform.isLinux then "${pname}-${version}-extracted/usr/share/cursor" else "Cursor.app";
66
67 tests = { };
68
69 updateScript = ./update.sh;
70
71 # Editing the `cursor` binary within the app bundle causes the bundle's signature
72 # to be invalidated, which prevents launching starting with macOS Ventura, because Cursor is notarized.
73 # See https://eclecticlight.co/2022/06/17/app-security-changes-coming-in-ventura/ for more information.
74 dontFixup = stdenv.hostPlatform.isDarwin;
75
76 # Cursor has no wrapper script.
77 patchVSCodePath = false;
78
79 meta = {
80 description = "AI-powered code editor built on vscode";
81 homepage = "https://cursor.com";
82 changelog = "https://cursor.com/changelog";
83 license = lib.licenses.unfree;
84 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
85 maintainers = with lib.maintainers; [
86 aspauldingcode
87 prince213
88 ];
89 platforms = [
90 "aarch64-linux"
91 "x86_64-linux"
92 ]
93 ++ lib.platforms.darwin;
94 mainProgram = "cursor";
95 };
96}).overrideAttrs
97 (oldAttrs: {
98 nativeBuildInputs =
99 (oldAttrs.nativeBuildInputs or [ ]) ++ lib.optionals hostPlatform.isDarwin [ undmg ];
100
101 passthru = (oldAttrs.passthru or { }) // {
102 inherit sources;
103 };
104 })