Skip to content
This repository was archived by the owner on Dec 2, 2025. It is now read-only.

Commit 96d7cce

Browse files
committed
Initial commit
0 parents  commit 96d7cce

File tree

3 files changed

+217
-0
lines changed

3 files changed

+217
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
build/
2+
result

flake.lock

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
{
2+
description = "Flake for building Cursor on Linux ARM and Windows ARM platforms";
3+
4+
inputs = {
5+
# Pinned to align the version of VS Codium with Cursor's build.
6+
nixpkgs.url = "github:NixOS/nixpkgs/212defe037698e18fc9521dfe451779a8979844c";
7+
};
8+
9+
outputs = { self, nixpkgs }:
10+
let
11+
supportedSystems = [ "aarch64-linux" "armv7l-linux" "x86_64-linux" ];
12+
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
13+
in
14+
{
15+
packages = forAllSystems (system:
16+
let
17+
pkgs = import nixpkgs { inherit system; };
18+
19+
# It's difficult to find pinned versions of Cursor.
20+
# The latest version and download URL were found here:
21+
# https://changelog.cursor.sh/
22+
cursorVersion = "0.40";
23+
# This is the VS Code version that Cursor was built on.
24+
vscodeVersion = "1.91.1";
25+
26+
cursorSrc = pkgs.appimageTools.extractType2 {
27+
name = "cursor-appimage";
28+
src = pkgs.fetchurl {
29+
url = "https://dl.todesktop.com/230313mzl4w4u92/linux/appimage/x64";
30+
sha256 = "sha256-ZURE8UoLPw+Qo1e4xuwXgc+JSwGrgb/6nfIGXMacmSg=";
31+
};
32+
};
33+
vscodeLinuxArm64 = builtins.fetchTarball {
34+
url = "https://update.code.visualstudio.com/${vscodeVersion}/linux-arm64/stable";
35+
sha256 = "sha256:1rpd014rw7ccaq7vysdbf3crkmlb9gxdkdpvzghn1jcgvqd99880";
36+
};
37+
vscodeLinuxArm32 = builtins.fetchTarball {
38+
url = "https://update.code.visualstudio.com/${vscodeVersion}/linux-armhf/stable";
39+
sha256 = "sha256:0a5lygf6b7m8pj5h20dzif52radf41g3hazx4zhky370gq3xrgwd";
40+
};
41+
vscodeWindowsArm64 = pkgs.fetchzip {
42+
stripRoot = false;
43+
url = "https://update.code.visualstudio.com/${vscodeVersion}/win32-arm64-archive/stable#file.zip";
44+
sha256 = "sha256-2pAXxDyDOazfOndQzydQCzXXBHCwQ5tgrs4RyCqcslw=";
45+
};
46+
47+
# Copies Cursor-specific resources into the VS Code package.
48+
copyCursorFiles = root: ''
49+
cp -R ${cursorSrc}/resources/app/out ${root}/resources/app/
50+
cp -R ${cursorSrc}/resources/app/*.json ${root}/resources/app/
51+
cp -R ${cursorSrc}/resources/app/extensions/cursor-* ${root}/resources/app/extensions/
52+
rm -rf "${root}/resources/app/node_modules"{,.asar}
53+
cp -R ${cursorSrc}/resources/app/node_modules.asar ${root}/resources/app/
54+
rm -rf ${root}/resources/app/resources
55+
cp -R ${cursorSrc}/resources/app/resources ${root}/resources/app/
56+
'';
57+
58+
# Overrides the VS Code package with Cursor's resources.
59+
buildCursorNix = { vscodePackage }:
60+
vscodePackage.overrideAttrs (oldAttrs: {
61+
pname = "cursor";
62+
version = cursorVersion;
63+
64+
postInstall = (oldAttrs.postInstall or "") + ''
65+
${(copyCursorFiles "$out/lib/vscode")}
66+
67+
# Replace VS Code's icon and desktop file with Cursor's
68+
cp ${cursorSrc}/cursor.png $out/share/pixmaps/cursor.png
69+
cp ${cursorSrc}/cursor.desktop $out/share/applications/cursor.desktop
70+
71+
# Rename the binary
72+
mv $out/bin/code $out/bin/cursor || true
73+
mv $out/bin/codium $out/bin/cursor || true
74+
'';
75+
76+
meta = oldAttrs.meta // {
77+
description = "Cursor ${cursorVersion}";
78+
};
79+
});
80+
81+
# Builds Cursor using a prepackaged set of VS Code files.
82+
# This is for creating dynamically linked builds.
83+
buildCursorPrepackaged = { vscodeFiles, name, isWindows ? false }:
84+
pkgs.stdenv.mkDerivation {
85+
pname = "cursor-${name}";
86+
version = cursorVersion;
87+
src = vscodeFiles;
88+
dontPatchShebangs = true;
89+
buildPhase = ''
90+
cp -R --preserve=mode,timestamps . $out
91+
92+
${copyCursorFiles "$out"}
93+
94+
# Replace VS Code's icon and desktop file with Cursor's
95+
cp ${cursorSrc}/cursor.png $out/cursor.png
96+
cp ${cursorSrc}/cursor.desktop $out/cursor.desktop
97+
cp -R ${cursorSrc}/resources/todesktop* $out/resources/
98+
99+
# This is excluded intentionally. It causes an error in console,
100+
# but there's some token we must be missing?
101+
# cp ${cursorSrc}/resources/app-update.yml $out/resources/
102+
103+
# Cursor doesn't have a root bin dir
104+
rm -rf $out/bin
105+
106+
mv $out/code $out/cursor || true
107+
mv $out/codium $out/cursor || true
108+
mv $out/Code.exe $out/Cursor.exe || true
109+
110+
# Platform-specific adjustments
111+
${if !isWindows then ''
112+
cp -R ${cursorSrc}/usr $out
113+
cp ${cursorSrc}/AppRun $out
114+
cp ${cursorSrc}/.DirIcon $out
115+
'' else ''
116+
''}
117+
'';
118+
};
119+
in
120+
{
121+
extract-vscode-version = pkgs.runCommand "extract-vscode-version" { } ''
122+
${pkgs.jq}/bin/jq -r .vscodeVersion ${cursorSrc}/resources/app/product.json >> $out
123+
'';
124+
125+
cursor = {
126+
linux = {
127+
arm64 = buildCursorPrepackaged {
128+
vscodeFiles = vscodeLinuxArm64;
129+
name = "linux-arm64";
130+
};
131+
arm64-appimage = pkgs.stdenv.mkDerivation {
132+
name = "cursor-linux-arm64-appimage";
133+
src = self.packages.${system}.cursor.linux.arm64;
134+
dontPatchShebangs = true;
135+
buildInputs = [ pkgs.appimagekit ];
136+
buildPhase = ''
137+
mkdir -p $out
138+
ARCH=arm_aarch64 appimagetool $src $out/cursor.AppImage
139+
chmod +x $out/cursor.AppImage
140+
patchelf --set-interpreter /lib/ld-linux-aarch64.so.1 $out/cursor.AppImage
141+
'';
142+
};
143+
arm64-targz = pkgs.runCommand "tarball" { } ''
144+
mkdir -p $out
145+
cd ${self.packages.${system}.cursor.linux.arm64}
146+
${pkgs.gnutar}/bin/tar -czvf $out/cursor-linux-arm64-${cursorVersion}.tar.gz .
147+
'';
148+
149+
arm32 = buildCursorPrepackaged {
150+
vscodeFiles = vscodeLinuxArm32;
151+
name = "linux-arm32";
152+
};
153+
arm32-appimage = pkgs.stdenv.mkDerivation {
154+
name = "cursor-linux-arm32-appimage";
155+
src = self.packages.${system}.cursor.linux.arm32;
156+
dontPatchShebangs = true;
157+
buildInputs = [ pkgs.appimagekit ];
158+
buildPhase = ''
159+
mkdir -p $out
160+
ARCH=arm appimagetool $src $out/cursor.AppImage
161+
chmod +x $out/cursor.AppImage
162+
patchelf --set-interpreter /lib/ld-linux.so.3 $out/cursor.AppImage
163+
'';
164+
};
165+
arm32-targz = pkgs.runCommand "tarball" { } ''
166+
mkdir -p $out
167+
cd ${self.packages.${system}.cursor.linux.arm32}
168+
${pkgs.gnutar}/bin/tar -czvf $out/cursor-linux-arm32-${cursorVersion}.tar.gz .
169+
'';
170+
};
171+
windows = {
172+
arm64 = buildCursorPrepackaged {
173+
vscodeFiles = vscodeWindowsArm64;
174+
name = "windows-arm64";
175+
isWindows = true;
176+
};
177+
};
178+
179+
nix = buildCursorNix {
180+
vscodePackage = pkgs.vscodium;
181+
};
182+
};
183+
184+
default = self.packages.${system}.cursor.nix;
185+
}
186+
);
187+
};
188+
}

0 commit comments

Comments
 (0)