mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 08:53:21 +00:00
code-server: 4.19.1 -> 4.23.1
In addition to the version bump, I did some refactoring because there were a few issues: 1. Downloading NPM dependencies during install phase does not work. Instead, copy them over from the build phase. 2. Native modules in lib/vscode were not being installed/built at all. 3. Kerberos module will not build (a new issue that appeared as a consequence of fixing the previous issue). Remove it for now. 4. Increase max-old-space-size from the default (I was running out of memory). There are still some issues to look over but these changes are at least an improvement over the status quo. Co-authored-by: Pol Dellaiera <pol.dellaiera@protonmail.com>
This commit is contained in:
parent
750bea5d48
commit
5f830f5fac
@ -71,18 +71,18 @@ let
|
|||||||
# To compute the commit when upgrading this derivation, do:
|
# To compute the commit when upgrading this derivation, do:
|
||||||
# `$ git rev-parse <git-rev>` where <git-rev> is the git revision of the `src`
|
# `$ git rev-parse <git-rev>` where <git-rev> is the git revision of the `src`
|
||||||
# Example: `$ git rev-parse v4.16.1`
|
# Example: `$ git rev-parse v4.16.1`
|
||||||
commit = "0c98611e6b43803a9d5dba222d7023b569abfb49";
|
commit = "9a28bc29dbddb6886dfe03dc1c31320249a901ce";
|
||||||
in
|
in
|
||||||
stdenv.mkDerivation (finalAttrs: {
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
pname = "code-server";
|
pname = "code-server";
|
||||||
version = "4.19.1";
|
version = "4.23.1";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
src = fetchFromGitHub {
|
||||||
owner = "coder";
|
owner = "coder";
|
||||||
repo = "code-server";
|
repo = "code-server";
|
||||||
rev = "v${finalAttrs.version}";
|
rev = "v${finalAttrs.version}";
|
||||||
fetchSubmodules = true;
|
fetchSubmodules = true;
|
||||||
hash = "sha256-J+6zuqVf1YKQjiRiqO4867DEwYzZsgQYgbsRXPo2hwY=";
|
hash = "sha256-nOfdEbnnNLfePhqGSXD/2A0DxqoJCo8U18VFYnNvFMU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
yarnCache = stdenv.mkDerivation {
|
yarnCache = stdenv.mkDerivation {
|
||||||
@ -114,7 +114,7 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
|
|
||||||
outputHashMode = "recursive";
|
outputHashMode = "recursive";
|
||||||
outputHashAlgo = "sha256";
|
outputHashAlgo = "sha256";
|
||||||
outputHash = "sha256-g2rwB+PuWuYgrzIuW0ngia7cdPMC8s7ffBEkbmPPzB4=";
|
outputHash = "sha256-MxUQ9Gw7MabLKPs5j8+Q4v7IULr68Pd/OIBWpfZ+rVU=";
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
@ -130,9 +130,12 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
quilt
|
quilt
|
||||||
];
|
];
|
||||||
|
|
||||||
buildInputs = lib.optionals (!stdenv.isDarwin) [ libsecret ]
|
buildInputs = [
|
||||||
++ (with xorg; [ libX11 libxkbfile ])
|
xorg.libX11
|
||||||
++ lib.optionals stdenv.isDarwin [
|
xorg.libxkbfile
|
||||||
|
] ++ lib.optionals (!stdenv.isDarwin) [
|
||||||
|
libsecret
|
||||||
|
] ++ lib.optionals stdenv.isDarwin [
|
||||||
AppKit
|
AppKit
|
||||||
Cocoa
|
Cocoa
|
||||||
CoreServices
|
CoreServices
|
||||||
@ -154,9 +157,9 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
|
|
||||||
# inject git commit
|
# inject git commit
|
||||||
substituteInPlace ./ci/build/build-vscode.sh \
|
substituteInPlace ./ci/build/build-vscode.sh \
|
||||||
--replace '$(git rev-parse HEAD)' "${commit}"
|
--replace-fail '$(git rev-parse HEAD)' "${commit}"
|
||||||
substituteInPlace ./ci/build/build-release.sh \
|
substituteInPlace ./ci/build/build-release.sh \
|
||||||
--replace '$(git rev-parse HEAD)' "${commit}"
|
--replace-fail '$(git rev-parse HEAD)' "${commit}"
|
||||||
'';
|
'';
|
||||||
|
|
||||||
configurePhase = ''
|
configurePhase = ''
|
||||||
@ -193,29 +196,15 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
|
|
||||||
# install code-server dependencies
|
# Apply patches.
|
||||||
yarn --offline --ignore-scripts
|
|
||||||
|
|
||||||
# apply patches
|
|
||||||
quilt push -a
|
quilt push -a
|
||||||
|
|
||||||
# patch shebangs of everything to allow binary packages to build
|
|
||||||
patchShebangs .
|
|
||||||
|
|
||||||
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1
|
||||||
export SKIP_SUBMODULE_DEPS=1
|
export SKIP_SUBMODULE_DEPS=1
|
||||||
export NODE_OPTIONS=--openssl-legacy-provider
|
export NODE_OPTIONS="--openssl-legacy-provider --max-old-space-size=4096"
|
||||||
|
|
||||||
# rebuild binary packages now that scripts have been patched
|
# Remove all built-in extensions, as these are 3rd party extensions that
|
||||||
echo "----- NPM rebuild"
|
# get downloaded from the VS Code marketplace.
|
||||||
npm rebuild --prefer-offline
|
|
||||||
|
|
||||||
# Replicate ci/dev/postinstall.sh
|
|
||||||
echo "----- Replicate ci/dev/postinstall.sh"
|
|
||||||
yarn --cwd "./vendor" install --modules-folder modules --offline --ignore-scripts --frozen-lockfile
|
|
||||||
|
|
||||||
# remove all built-in extensions, as these are 3rd party extensions that
|
|
||||||
# get downloaded from vscode marketplace
|
|
||||||
jq --slurp '.[0] * .[1]' "./lib/vscode/product.json" <(
|
jq --slurp '.[0] * .[1]' "./lib/vscode/product.json" <(
|
||||||
cat << EOF
|
cat << EOF
|
||||||
{
|
{
|
||||||
@ -224,26 +213,42 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
EOF
|
EOF
|
||||||
) | sponge ./lib/vscode/product.json
|
) | sponge ./lib/vscode/product.json
|
||||||
|
|
||||||
# disable automatic updates
|
# Disable automatic updates.
|
||||||
sed -i '/update.mode/,/\}/{s/default:.*/default: "none",/g}' \
|
sed -i '/update.mode/,/\}/{s/default:.*/default: "none",/g}' \
|
||||||
lib/vscode/src/vs/platform/update/common/update.config.contribution.ts
|
lib/vscode/src/vs/platform/update/common/update.config.contribution.ts
|
||||||
|
|
||||||
# Patch out remote download of nodejs from build script
|
# Patch out remote download of nodejs from build script.
|
||||||
patch -p1 -i ${./remove-node-download.patch}
|
patch -p1 -i ${./remove-node-download.patch}
|
||||||
|
|
||||||
# Fetch packages for vscode
|
# Install dependencies.
|
||||||
find ./lib/vscode -name "yarn.lock" -printf "%h\n" | \
|
patchShebangs .
|
||||||
|
find . -name "yarn.lock" -printf "%h\n" | \
|
||||||
xargs -I {} yarn --cwd {} \
|
xargs -I {} yarn --cwd {} \
|
||||||
--frozen-lockfile --ignore-scripts --ignore-engines
|
--offline --frozen-lockfile --ignore-scripts --ignore-engines
|
||||||
|
|
||||||
# patch shebangs of everything to allow binary packages to build
|
|
||||||
patchShebangs .
|
patchShebangs .
|
||||||
|
|
||||||
|
# Use esbuild from nixpkgs.
|
||||||
${patchEsbuild "./lib/vscode/build" "0.12.6"}
|
${patchEsbuild "./lib/vscode/build" "0.12.6"}
|
||||||
${patchEsbuild "./lib/vscode/extensions" "0.11.23"}
|
${patchEsbuild "./lib/vscode/extensions" "0.11.23"}
|
||||||
|
|
||||||
|
# Kerberos errors while building, so remove it for now as it is not
|
||||||
|
# required.
|
||||||
|
yarn remove kerberos --cwd lib/vscode/remote --offline --frozen-lockfile --ignore-scripts --ignore-engines
|
||||||
|
|
||||||
|
# Put ripgrep binary into bin, so post-install does not try to download it.
|
||||||
|
find -name ripgrep -type d \
|
||||||
|
-execdir mkdir -p {}/bin \; \
|
||||||
|
-execdir ln -s ${ripgrep}/bin/rg {}/bin/rg \;
|
||||||
|
|
||||||
|
# Run post-install scripts after patching.
|
||||||
|
find ./lib/vscode \( -path "*/node_modules/*" -or -path "*/extensions/*" \) \
|
||||||
|
-and -type f -name "yarn.lock" -printf "%h\n" | \
|
||||||
|
xargs -I {} sh -c 'jq -e ".scripts.postinstall" {}/package.json >/dev/null && yarn --cwd {} postinstall --frozen-lockfile --offline || true'
|
||||||
|
patchShebangs .
|
||||||
|
|
||||||
'' + lib.optionalString stdenv.isDarwin ''
|
'' + lib.optionalString stdenv.isDarwin ''
|
||||||
# use prebuilt binary for @parcel/watcher, which requires macOS SDK 10.13+
|
# Use prebuilt binary for @parcel/watcher, which requires macOS SDK 10.13+
|
||||||
# (see issue #101229)
|
# (see issue #101229).
|
||||||
pushd ./lib/vscode/remote/node_modules/@parcel/watcher
|
pushd ./lib/vscode/remote/node_modules/@parcel/watcher
|
||||||
mkdir -p ./build/Release
|
mkdir -p ./build/Release
|
||||||
mv ./prebuilds/darwin-x64/node.napi.glibc.node ./build/Release/watcher.node
|
mv ./prebuilds/darwin-x64/node.napi.glibc.node ./build/Release/watcher.node
|
||||||
@ -251,23 +256,15 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
popd
|
popd
|
||||||
'' + ''
|
'' + ''
|
||||||
|
|
||||||
# put ripgrep binary into bin, so postinstall does not try to download it
|
# Build binary packages (argon2, node-pty, etc).
|
||||||
find -name ripgrep -type d \
|
npm rebuild --offline
|
||||||
-execdir mkdir -p {}/bin \; \
|
npm rebuild --offline --prefix lib/vscode/remote
|
||||||
-execdir ln -s ${ripgrep}/bin/rg {}/bin/rg \;
|
|
||||||
|
|
||||||
# run postinstall scripts after patching
|
# Build code-server and VS Code.
|
||||||
find ./lib/vscode \( -path "*/node_modules/*" -or -path "*/extensions/*" \) \
|
|
||||||
-and -type f -name "yarn.lock" -printf "%h\n" | \
|
|
||||||
xargs -I {} sh -c 'jq -e ".scripts.postinstall" {}/package.json >/dev/null && yarn --cwd {} postinstall --frozen-lockfile --offline || true'
|
|
||||||
|
|
||||||
# build code-server
|
|
||||||
yarn build
|
yarn build
|
||||||
|
|
||||||
# build vscode
|
|
||||||
VERSION=${finalAttrs.version} yarn build:vscode
|
VERSION=${finalAttrs.version} yarn build:vscode
|
||||||
|
|
||||||
# inject version into package.json
|
# Inject version into package.json.
|
||||||
jq --slurp '.[0] * .[1]' ./package.json <(
|
jq --slurp '.[0] * .[1]' ./package.json <(
|
||||||
cat << EOF
|
cat << EOF
|
||||||
{
|
{
|
||||||
@ -276,8 +273,12 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
EOF
|
EOF
|
||||||
) | sponge ./package.json
|
) | sponge ./package.json
|
||||||
|
|
||||||
# create release
|
# Create release, keeping all dependencies.
|
||||||
yarn release
|
KEEP_MODULES=1 yarn release
|
||||||
|
|
||||||
|
# Prune development dependencies. We only need to do this for the root as
|
||||||
|
# the VS Code build process already does this for VS Code.
|
||||||
|
npm prune --omit=dev --prefix release
|
||||||
|
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
@ -290,9 +291,6 @@ stdenv.mkDerivation (finalAttrs: {
|
|||||||
# copy release to libexec path
|
# copy release to libexec path
|
||||||
cp -R -T release "$out/libexec/code-server"
|
cp -R -T release "$out/libexec/code-server"
|
||||||
|
|
||||||
# install only production dependencies
|
|
||||||
yarn --offline --cwd "$out/libexec/code-server" --production
|
|
||||||
|
|
||||||
# create wrapper
|
# create wrapper
|
||||||
makeWrapper "${nodejs}/bin/node" "$out/bin/code-server" \
|
makeWrapper "${nodejs}/bin/node" "$out/bin/code-server" \
|
||||||
--add-flags "$out/libexec/code-server/out/node/entry.js"
|
--add-flags "$out/libexec/code-server/out/node/entry.js"
|
||||||
|
Loading…
Reference in New Issue
Block a user