tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
lol
0
fork
atom
overview
issues
pulls
pipelines
code-server: 3.12.0 -> 4.0.1
Derek Guenther
4 years ago
72501ea6
f38e647a
+80
-43
5 changed files
expand all
collapse all
unified
split
pkgs
servers
code-server
default.nix
playwright.patch
remove-cloud-agent-download.patch
remove-node-download.patch
top-level
all-packages.nix
+43
-35
pkgs/servers/code-server/default.nix
···
1
1
{ lib, stdenv, fetchFromGitHub, buildGoModule, makeWrapper, runCommand
2
2
-
, moreutils, jq, git, cacert, zip, rsync, pkg-config, yarn, python3
3
3
-
, esbuild, nodejs-14_x, libsecret, xorg, ripgrep
4
4
-
, AppKit, Cocoa, Security, cctools }:
2
2
+
, cacert, moreutils, jq, git, rsync, pkg-config, yarn, python3
3
3
+
, esbuild, nodejs-14_x, node-gyp, libsecret, xorg, ripgrep
4
4
+
, AppKit, Cocoa, CoreServices, Security, cctools, xcbuild }:
5
5
6
6
let
7
7
system = stdenv.hostPlatform.system;
···
11
11
yarn' = yarn.override { inherit nodejs; };
12
12
defaultYarnOpts = [ "frozen-lockfile" "non-interactive" "no-progress"];
13
13
14
14
+
# replaces esbuild's download script with a binary from nixpkgs
15
15
+
patchEsbuild = path : version : ''
16
16
+
mkdir -p ${path}/node_modules/esbuild/bin
17
17
+
jq "del(.scripts.postinstall)" ${path}/node_modules/esbuild/package.json | sponge ${path}/node_modules/esbuild/package.json
18
18
+
sed -i 's/${version}/${esbuild.version}/g' ${path}/node_modules/esbuild/lib/main.js
19
19
+
ln -s -f ${esbuild}/bin/esbuild ${path}/node_modules/esbuild/bin/esbuild
20
20
+
'';
21
21
+
14
22
in stdenv.mkDerivation rec {
15
23
pname = "code-server";
16
16
-
version = "3.12.0";
17
17
-
commit = "798dc0baf284416dbbf951e4ef596beeab6cb6c4";
24
24
+
version = "4.0.1";
25
25
+
commit = "7fe23daf009e5234eaa54a1ea5ff26df384c47ac";
18
26
19
27
src = fetchFromGitHub {
20
28
owner = "cdr";
21
29
repo = "code-server";
22
30
rev = "v${version}";
23
23
-
sha256 = "17v3sz0wjrmikmzyh9xswr4kf1vcj9njlibqb4wwj0pq0d72wdvl";
31
31
+
sha256 = "1s3dcmzlkyh7qfs3ai1p7dlp45iys0ax1fbxxz17p395pw9anrrl";
24
32
};
25
33
26
34
cloudAgent = buildGoModule rec {
···
63
71
outputHashAlgo = "sha256";
64
72
65
73
# to get hash values use nix-build -A code-server.prefetchYarnCache
66
66
-
outputHash = {
67
67
-
x86_64-linux = "1clfdl9hy5j2dj6jj6a9vgq0wzllfj0h2hbb73959k3w85y4ad2w";
68
68
-
aarch64-linux = "1clfdl9hy5j2dj6jj6a9vgq0wzllfj0h2hbb73959k3w85y4ad2w";
69
69
-
x86_64-darwin = "1clfdl9hy5j2dj6jj6a9vgq0wzllfj0h2hbb73959k3w85y4ad2w";
70
70
-
}.${system} or (throw "Unsupported system ${system}");
74
74
+
outputHash = "0qmfsirld1qfl2s26rxbpmvxsyj2pvzkgk8w89zlrgbhgc5fj8p9";
71
75
};
72
76
73
73
-
# Extract the Node.js source code which is used to compile packages with
74
74
-
# native bindings
75
75
-
nodeSources = runCommand "node-sources" {} ''
76
76
-
tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
77
77
-
mv node-* $out
78
78
-
'';
79
79
-
80
77
nativeBuildInputs = [
81
81
-
nodejs yarn' python pkg-config zip makeWrapper git rsync jq moreutils
78
78
+
nodejs yarn' python pkg-config makeWrapper git rsync jq moreutils
82
79
];
83
80
buildInputs = lib.optionals (!stdenv.isDarwin) [ libsecret ]
84
81
++ (with xorg; [ libX11 libxkbfile ])
85
82
++ lib.optionals stdenv.isDarwin [
86
86
-
AppKit Cocoa Security cctools
83
83
+
AppKit Cocoa CoreServices Security cctools xcbuild
87
84
];
88
85
89
86
patches = [
···
119
116
120
117
# skip unnecessary electron download
121
118
export ELECTRON_SKIP_BINARY_DOWNLOAD=1
122
122
-
'' + lib.optionalString stdenv.isLinux ''
123
123
-
# set nodedir, so we can build binaries later
124
124
-
npm config set nodedir "${nodeSources}"
119
119
+
120
120
+
# set nodedir to prevent node-gyp from downloading headers
121
121
+
# taken from https://nixos.org/manual/nixpkgs/stable/#javascript-tool-specific
122
122
+
mkdir -p $HOME/.node-gyp/${nodejs.version}
123
123
+
echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion
124
124
+
ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version}
125
125
+
export npm_config_nodedir=${nodejs}
126
126
+
127
127
+
# use updated node-gyp. fixes the following error on Darwin:
128
128
+
# PermissionError: [Errno 1] Operation not permitted: '/usr/sbin/pkgutil'
129
129
+
export npm_config_node_gyp=${node-gyp}/lib/node_modules/node-gyp/bin/node-gyp.js
125
130
'';
126
131
127
132
buildPhase = ''
···
169
174
# sw_vers before that variable is checked.
170
175
patch -p1 -i ${./playwright.patch}
171
176
177
177
+
# Patch out remote download of nodejs from build script
178
178
+
patch -p1 -i ${./remove-node-download.patch}
179
179
+
172
180
# Replicate install vscode dependencies without running script for all vscode packages
173
181
# that require patching for postinstall scripts to succeed
174
182
find ./vendor/modules/code-oss-dev -path "*node_modules" -prune -o \
175
183
-path "./*/*/*/*/*" -name "yarn.lock" -printf "%h\n" | \
176
184
xargs -I {} yarn --cwd {} \
177
185
--frozen-lockfile --offline --ignore-scripts --ignore-engines
186
186
+
178
187
179
188
# patch shebangs of everything to allow binary packages to build
180
189
patchShebangs .
181
190
182
182
-
# patch build esbuild
183
183
-
mkdir -p vendor/modules/code-oss-dev/build/node_modules/esbuild/bin
184
184
-
jq "del(.scripts.postinstall)" vendor/modules/code-oss-dev/build/node_modules/esbuild/package.json | sponge vendor/modules/code-oss-dev/build/node_modules/esbuild/package.json
185
185
-
sed -i 's/0.12.6/${esbuild.version}/g' vendor/modules/code-oss-dev/build/node_modules/esbuild/lib/main.js
186
186
-
ln -s -f ${esbuild}/bin/esbuild vendor/modules/code-oss-dev/build/node_modules/esbuild/bin/esbuild
187
187
-
188
188
-
# patch extensions esbuild
189
189
-
mkdir -p vendor/modules/code-oss-dev/extensions/node_modules/esbuild/bin
190
190
-
jq "del(.scripts.postinstall)" vendor/modules/code-oss-dev/extensions/node_modules/esbuild/package.json | sponge vendor/modules/code-oss-dev/extensions/node_modules/esbuild/package.json
191
191
-
sed -i 's/0.11.12/${esbuild.version}/g' vendor/modules/code-oss-dev/extensions/node_modules/esbuild/lib/main.js
192
192
-
ln -s -f ${esbuild}/bin/esbuild vendor/modules/code-oss-dev/extensions/node_modules/esbuild/bin/esbuild
193
193
-
191
191
+
${patchEsbuild "./vendor/modules/code-oss-dev/build" "0.12.6"}
192
192
+
${patchEsbuild "./vendor/modules/code-oss-dev/extensions" "0.11.23"}
193
193
+
'' + lib.optionalString stdenv.isDarwin ''
194
194
+
# use prebuilt binary for @parcel/watcher, which requires macOS SDK 10.13+
195
195
+
# (see issue #101229)
196
196
+
pushd ./vendor/modules/code-oss-dev/remote/node_modules/@parcel/watcher
197
197
+
mkdir -p ./build/Release
198
198
+
mv ./prebuilds/darwin-x64/node.napi.glibc.node ./build/Release/watcher.node
199
199
+
jq "del(.scripts) | .gypfile = false" ./package.json | sponge ./package.json
200
200
+
popd
201
201
+
'' + ''
194
202
# rebuild binaries, we use npm here, as yarn does not provide an alternative
195
203
# that would not attempt to try to reinstall everything and break our
196
204
# patching attempts
+2
-2
pkgs/servers/code-server/playwright.patch
···
4
4
* limitations under the License.
5
5
*/
6
6
7
7
-
-const { installBrowsersWithProgressBar } = require('./lib/install/installer');
7
7
+
-const { installDefaultBrowsersForNpmInstall } = require('playwright-core/lib/utils/registry');
8
8
-
9
9
-
-installBrowsersWithProgressBar();
9
9
+
-installDefaultBrowsersForNpmInstall();
10
10
+process.stdout.write('Browser install disabled by Nix build script\n');
+6
-5
pkgs/servers/code-server/remove-cloud-agent-download.patch
···
1
1
--- ./ci/build/npm-postinstall.sh
2
2
+++ ./ci/build/npm-postinstall.sh
3
3
-
@@ -56,13 +56,6 @@
4
4
-
;;
5
5
-
esac
6
6
-
7
7
-
- OS="$(uname | tr '[:upper:]' '[:lower:]')"
3
3
+
@@ -58,14 +58,6 @@
4
4
+
5
5
+
OS="$(uname | tr '[:upper:]' '[:lower:]')"
6
6
+
7
7
+
- mkdir -p ./lib
8
8
+
-
8
9
- if curl -fsSL "https://github.com/cdr/cloud-agent/releases/latest/download/cloud-agent-$OS-$ARCH" -o ./lib/coder-cloud-agent; then
9
10
- chmod +x ./lib/coder-cloud-agent
10
11
- else
+27
pkgs/servers/code-server/remove-node-download.patch
···
1
1
+
--- ./vendor/modules/code-oss-dev/build/gulpfile.reh.js
2
2
+
+++ ./vendor/modules/code-oss-dev/build/gulpfile.reh.js
3
3
+
@@ -277,8 +277,6 @@
4
4
+
.pipe(util.stripSourceMappingURL())
5
5
+
.pipe(jsFilter.restore);
6
6
+
7
7
+
- const nodePath = `.build/node/v${nodeVersion}/${platform}-${platform === 'darwin' ? 'x64' : arch}`;
8
8
+
- const node = gulp.src(`${nodePath}/**`, { base: nodePath, dot: true });
9
9
+
10
10
+
let web = [];
11
11
+
if (type === 'reh-web') {
12
12
+
@@ -296,7 +294,6 @@
13
13
+
license,
14
14
+
sources,
15
15
+
deps,
16
16
+
- node,
17
17
+
...web
18
18
+
);
19
19
+
20
20
+
@@ -376,7 +373,6 @@
21
21
+
const destinationFolderName = `vscode-${type}${dashed(platform)}${dashed(arch)}`;
22
22
+
23
23
+
const serverTaskCI = task.define(`vscode-${type}${dashed(platform)}${dashed(arch)}${dashed(minified)}-ci`, task.series(
24
24
+
- gulp.task(`node-${platform}-${platform === 'darwin' ? 'x64' : arch}`),
25
25
+
util.rimraf(path.join(BUILD_ROOT, destinationFolderName)),
26
26
+
packageTask(type, platform, arch, sourceFolderName, destinationFolderName)
27
27
+
));
+2
-1
pkgs/top-level/all-packages.nix
···
29365
29365
};
29366
29366
29367
29367
code-server = callPackage ../servers/code-server {
29368
29368
-
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Security;
29368
29368
+
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa CoreServices Security;
29369
29369
inherit (darwin) cctools;
29370
29370
+
inherit (nodePackages) node-gyp;
29370
29371
};
29371
29372
29372
29373
vue = callPackage ../applications/misc/vue { };