-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
code-cursor: use generic vscode package builder #413785
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,57 +1,18 @@ | ||
| { | ||
| lib, | ||
| stdenvNoCC, | ||
| stdenv, | ||
| callPackage, | ||
| vscode-generic, | ||
| fetchurl, | ||
|
|
||
| # build | ||
| appimageTools, | ||
|
|
||
| # linux dependencies | ||
| alsa-lib, | ||
| at-spi2-atk, | ||
| autoPatchelfHook, | ||
| cairo, | ||
| cups, | ||
| curlWithGnuTls, | ||
| egl-wayland, | ||
| expat, | ||
| fontconfig, | ||
| freetype, | ||
| ffmpeg, | ||
| glib, | ||
| glibc, | ||
| glibcLocales, | ||
| gtk3, | ||
| libappindicator-gtk3, | ||
| libdrm, | ||
| libgbm, | ||
| libGL, | ||
| libnotify, | ||
| libva-minimal, | ||
| libxkbcommon, | ||
| libxkbfile, | ||
| makeWrapper, | ||
| nspr, | ||
| nss, | ||
| pango, | ||
| pciutils, | ||
| pulseaudio, | ||
| vivaldi-ffmpeg-codecs, | ||
| vulkan-loader, | ||
| wayland, | ||
|
|
||
| # linux installation | ||
| rsync, | ||
| commandLineArgs ? "", | ||
|
|
||
| # darwin build | ||
| undmg, | ||
| commandLineArgs ? "", | ||
| useVSCodeRipgrep ? stdenv.hostPlatform.isDarwin, | ||
| }: | ||
| let | ||
| pname = "cursor"; | ||
| version = "1.0.0"; | ||
|
|
||
| inherit (stdenvNoCC) hostPlatform; | ||
| let | ||
| inherit (stdenv) hostPlatform; | ||
| finalCommandLineArgs = "--update=false " + commandLineArgs; | ||
|
|
||
| sources = { | ||
| x86_64-linux = fetchurl { | ||
|
|
@@ -73,115 +34,47 @@ let | |
| }; | ||
|
|
||
| source = sources.${hostPlatform.system}; | ||
|
|
||
| # Linux -- build from AppImage | ||
| appimageContents = appimageTools.extractType2 { | ||
| inherit version pname; | ||
| src = source; | ||
| }; | ||
|
|
||
| wrappedAppimage = appimageTools.wrapType2 { | ||
| inherit version pname; | ||
| src = source; | ||
| }; | ||
|
|
||
| in | ||
| stdenvNoCC.mkDerivation { | ||
| inherit pname version; | ||
|
|
||
| src = if hostPlatform.isLinux then wrappedAppimage else source; | ||
|
|
||
| nativeBuildInputs = | ||
| lib.optionals hostPlatform.isLinux [ | ||
| autoPatchelfHook | ||
| glibcLocales | ||
| makeWrapper | ||
| rsync | ||
| ] | ||
| ++ lib.optionals hostPlatform.isDarwin [ undmg ]; | ||
|
|
||
| buildInputs = lib.optionals hostPlatform.isLinux [ | ||
| alsa-lib | ||
| at-spi2-atk | ||
| cairo | ||
| cups | ||
| curlWithGnuTls | ||
| egl-wayland | ||
| expat | ||
| ffmpeg | ||
| glib | ||
| gtk3 | ||
| libdrm | ||
| libgbm | ||
| libGL | ||
| libva-minimal | ||
| libxkbcommon | ||
| libxkbfile | ||
| nspr | ||
| nss | ||
| pango | ||
| pulseaudio | ||
| vivaldi-ffmpeg-codecs | ||
| vulkan-loader | ||
| wayland | ||
| ]; | ||
| (callPackage vscode-generic rec { | ||
| inherit useVSCodeRipgrep; | ||
| commandLineArgs = finalCommandLineArgs; | ||
|
|
||
| runtimeDependencies = lib.optionals hostPlatform.isLinux [ | ||
| egl-wayland | ||
| ffmpeg | ||
| glibc | ||
| libappindicator-gtk3 | ||
| libnotify | ||
| libxkbfile | ||
| pciutils | ||
| pulseaudio | ||
| wayland | ||
| fontconfig | ||
| freetype | ||
| ]; | ||
|
|
||
| sourceRoot = lib.optionalString hostPlatform.isDarwin "."; | ||
|
|
||
| # Don't break code signing | ||
| dontUpdateAutotoolsGnuConfigScripts = hostPlatform.isDarwin; | ||
| dontConfigure = hostPlatform.isDarwin; | ||
| dontFixup = hostPlatform.isDarwin; | ||
| version = "1.0.0"; | ||
| pname = "cursor"; | ||
|
|
||
| installPhase = '' | ||
| runHook preInstall | ||
| mkdir -p $out/ | ||
| # You can find the current VSCode version in the About dialog: | ||
| # workbench.action.showAboutDialog (Help: About) | ||
| vscodeVersion = "1.96.2"; | ||
JohnRTitor marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| ${lib.optionalString hostPlatform.isLinux '' | ||
| cp -r bin $out/bin | ||
| # mkdir -p $out/share/cursor | ||
| # cp -ar ${appimageContents}/usr/share $out/ | ||
| executableName = "cursor"; | ||
| longName = "Cursor"; | ||
| shortName = "cursor"; | ||
| libraryName = "cursor"; | ||
| iconName = "cursor"; | ||
|
|
||
| rsync -a -q ${appimageContents}/usr/share $out/ --exclude "*.so" | ||
| src = | ||
| if hostPlatform.isLinux then | ||
| appimageTools.extract { | ||
| inherit pname version; | ||
| src = source; | ||
|
||
| } | ||
| else | ||
| source; | ||
|
|
||
| # Fix the desktop file to point to the correct location | ||
| substituteInPlace $out/share/applications/cursor.desktop --replace-fail "/usr/share/cursor/cursor" "$out/bin/cursor" | ||
| sourceRoot = | ||
| if hostPlatform.isLinux then "${pname}-${version}-extracted/usr/share/cursor" else "Cursor.app"; | ||
|
|
||
| wrapProgram $out/bin/cursor \ | ||
| --add-flags "--update=false" \ | ||
| --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}} --no-update" \ | ||
| --add-flags ${lib.escapeShellArg commandLineArgs} | ||
| ''} | ||
| tests = { }; | ||
|
|
||
| ${lib.optionalString hostPlatform.isDarwin '' | ||
| APP_DIR="$out/Applications" | ||
| mkdir -p "$APP_DIR" | ||
| cp -Rp Cursor.app "$APP_DIR" | ||
| mkdir -p "$out/bin" | ||
| ln -s "$APP_DIR/Cursor.app/Contents/Resources/app/bin/cursor" "$out/bin/cursor" | ||
| ''} | ||
| updateScript = ./update.sh; | ||
|
|
||
| runHook postInstall | ||
| ''; | ||
| # 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; | ||
|
|
||
| passthru = { | ||
| inherit sources; | ||
| updateScript = ./update.sh; | ||
| }; | ||
| # Cursor has no wrapper script. | ||
| patchVSCodePath = false; | ||
|
|
||
| meta = { | ||
| description = "AI-powered code editor built on vscode"; | ||
|
|
@@ -193,7 +86,26 @@ stdenvNoCC.mkDerivation { | |
| aspauldingcode | ||
| prince213 | ||
| ]; | ||
| platforms = lib.platforms.linux ++ lib.platforms.darwin; | ||
| 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; | ||
| }; | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Leave these in the
letblock so the updater can see them.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we are talking about the update.sh script, I believe I tested the update functionality and it worked fine. The version is extracted from the Nix package attribute: