diff options
Diffstat (limited to 'pkgs/servers/code-server/default.nix')
| -rw-r--r-- | pkgs/servers/code-server/default.nix | 99 |
1 files changed, 47 insertions, 52 deletions
diff --git a/pkgs/servers/code-server/default.nix b/pkgs/servers/code-server/default.nix index 4a8d19687f7f..44edf3be7a81 100644 --- a/pkgs/servers/code-server/default.nix +++ b/pkgs/servers/code-server/default.nix @@ -1,15 +1,15 @@ { lib, stdenv, fetchFromGitHub, buildGoModule, makeWrapper, runCommand , cacert, moreutils, jq, git, rsync, pkg-config, yarn, python3 -, esbuild, nodejs-14_x, node-gyp, libsecret, xorg, ripgrep -, AppKit, Cocoa, CoreServices, Security, cctools, xcbuild }: +, esbuild, nodejs-16_x, node-gyp, libsecret, xorg, ripgrep +, AppKit, Cocoa, CoreServices, Security, cctools, xcbuild, quilt }: let system = stdenv.hostPlatform.system; - nodejs = nodejs-14_x; + nodejs = nodejs-16_x; python = python3; yarn' = yarn.override { inherit nodejs; }; - defaultYarnOpts = [ "frozen-lockfile" "non-interactive" "no-progress"]; + defaultYarnOpts = [ ]; # replaces esbuild's download script with a binary from nixpkgs patchEsbuild = path : version : '' @@ -21,28 +21,28 @@ let in stdenv.mkDerivation rec { pname = "code-server"; - version = "4.0.1"; - commit = "7fe23daf009e5234eaa54a1ea5ff26df384c47ac"; + version = "4.8.3"; src = fetchFromGitHub { - owner = "cdr"; + owner = "coder"; repo = "code-server"; rev = "v${version}"; - sha256 = "1s3dcmzlkyh7qfs3ai1p7dlp45iys0ax1fbxxz17p395pw9anrrl"; + fetchSubmodules = true; + sha256 = "1h5ng60wf3gpsydfkv20x30xsw1f5zcvv77l1mzrqz1mhcw93lvz"; }; cloudAgent = buildGoModule rec { pname = "cloud-agent"; - version = "0.2.3"; + version = "0.2.6"; src = fetchFromGitHub { - owner = "cdr"; + owner = "coder"; repo = "cloud-agent"; rev = "v${version}"; - sha256 = "14i1qq273f0yn5v52ryiqwj7izkd1yd212di4gh4bqypmmzhw3jj"; + sha256 = "1s3jpgvzizc9skc27c3x35sya2p4ywhvdi3l73927z3j47wszy7f"; }; - vendorSha256 = "0k9v10wkzx53r5syf6bmm81gr4s5dalyaa07y9zvx6vv5r2h0661"; + vendorSha256 = "14xzlbmki8fk8mbcci62q8sklyd0nyga07ww1ap0vdrv7d1g31hn"; postPatch = '' # the cloud-agent release tag has an empty version string, so add it back in @@ -66,16 +66,20 @@ in stdenv.mkDerivation rec { xargs -I {} yarn --cwd {} \ --frozen-lockfile --ignore-scripts --ignore-platform \ --ignore-engines --no-progress --non-interactive + + find ./lib/vscode -name "yarn.lock" -printf "%h\n" | \ + xargs -I {} yarn --cwd {} \ + --ignore-scripts --ignore-engines ''; outputHashMode = "recursive"; outputHashAlgo = "sha256"; # to get hash values use nix-build -A code-server.prefetchYarnCache - outputHash = "0qmfsirld1qfl2s26rxbpmvxsyj2pvzkgk8w89zlrgbhgc5fj8p9"; + outputHash = "0jzzbmmgv1nfq975mi9ii9l6c4f1wy10fyy117xgm4s6vxana7qn"; }; nativeBuildInputs = [ - nodejs yarn' python pkg-config makeWrapper git rsync jq moreutils + nodejs yarn' python pkg-config makeWrapper git rsync jq moreutils quilt ]; buildInputs = lib.optionals (!stdenv.isDarwin) [ libsecret ] ++ (with xorg; [ libX11 libxkbfile ]) @@ -86,6 +90,8 @@ in stdenv.mkDerivation rec { patches = [ # remove download of coder-cloud agent ./remove-cloud-agent-download.patch + # remove git calls from vscode build script + ./build-vscode-nogit.patch ]; postPatch = '' @@ -133,79 +139,68 @@ in stdenv.mkDerivation rec { # install code-server dependencies yarn --offline --ignore-scripts + # apply patches + quilt push -a + # patch shebangs of everything to allow binary packages to build patchShebangs . - # Skip shellcheck download - jq "del(.scripts.preinstall)" node_modules/shellcheck/package.json | sponge node_modules/shellcheck/package.json + export PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD=1 + export SKIP_SUBMODULE_DEPS=1 + export NODE_OPTIONS=--openssl-legacy-provider # rebuild binary packages now that scripts have been patched - npm rebuild + echo "----- NPM rebuild" + 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 - # Replicate vendor/postinstall.sh - echo " ----- Replicate vendor/postinstall.sh" - yarn --cwd "./vendor/modules/code-oss-dev" --offline --frozen-lockfile --ignore-scripts install - # remove all built-in extensions, as these are 3rd party extensions that # get downloaded from vscode marketplace - jq --slurp '.[0] * .[1]' "vendor/modules/code-oss-dev/product.json" <( + jq --slurp '.[0] * .[1]' "./lib/vscode/product.json" <( cat << EOF { "builtInExtensions": [] } EOF - ) | sponge vendor/modules/code-oss-dev/product.json + ) | sponge ./lib/vscode/product.json # disable automatic updates sed -i '/update.mode/,/\}/{s/default:.*/default: "none",/g}' \ - vendor/modules/code-oss-dev/src/vs/platform/update/common/update.config.contribution.ts - - # put ripgrep binary into bin, so postinstall does not try to download it - find -name vscode-ripgrep -type d \ - -execdir mkdir -p {}/bin \; \ - -execdir ln -s ${ripgrep}/bin/rg {}/bin/rg \; - - # Playwright is only needed for tests, we can disable it for builds. - # There's an environment variable to disable downloads, but the package makes a breaking call to - # sw_vers before that variable is checked. - patch -p1 -i ${./playwright.patch} + lib/vscode/src/vs/platform/update/common/update.config.contribution.ts # Patch out remote download of nodejs from build script patch -p1 -i ${./remove-node-download.patch} - # Replicate install vscode dependencies without running script for all vscode packages - # that require patching for postinstall scripts to succeed - find ./vendor/modules/code-oss-dev -path "*node_modules" -prune -o \ - -path "./*/*/*/*/*" -name "yarn.lock" -printf "%h\n" | \ + # Fetch packages for vscode + find ./lib/vscode -name "yarn.lock" -printf "%h\n" | \ xargs -I {} yarn --cwd {} \ - --frozen-lockfile --offline --ignore-scripts --ignore-engines - + --frozen-lockfile --ignore-scripts --ignore-engines # patch shebangs of everything to allow binary packages to build patchShebangs . - ${patchEsbuild "./vendor/modules/code-oss-dev/build" "0.12.6"} - ${patchEsbuild "./vendor/modules/code-oss-dev/extensions" "0.11.23"} - '' + lib.optionalString stdenv.isDarwin '' + ${patchEsbuild "./lib/vscode/build" "0.12.6"} + ${patchEsbuild "./lib/vscode/extensions" "0.11.23"} + '' + lib.optionalString stdenv.isDarwin '' # use prebuilt binary for @parcel/watcher, which requires macOS SDK 10.13+ # (see issue #101229) - pushd ./vendor/modules/code-oss-dev/remote/node_modules/@parcel/watcher + pushd ./lib/vscode/remote/node_modules/@parcel/watcher mkdir -p ./build/Release mv ./prebuilds/darwin-x64/node.napi.glibc.node ./build/Release/watcher.node jq "del(.scripts) | .gypfile = false" ./package.json | sponge ./package.json popd '' + '' - # rebuild binaries, we use npm here, as yarn does not provide an alternative - # that would not attempt to try to reinstall everything and break our - # patching attempts - npm rebuild --prefix vendor/modules/code-oss-dev --update-binary + + # put ripgrep binary into bin, so postinstall does not try to download it + find -name ripgrep -type d \ + -execdir mkdir -p {}/bin \; \ + -execdir ln -s ${ripgrep}/bin/rg {}/bin/rg \; # run postinstall scripts after patching - find ./vendor/modules/code-oss-dev -path "*node_modules" -prune -o \ + find ./lib/vscode -path "*node_modules" -prune -o \ -path "./*/*/*/*/*" -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' @@ -233,7 +228,7 @@ in stdenv.mkDerivation rec { ln -s "${cloudAgent}/bin/cloud-agent" $out/libexec/code-server/lib/coder-cloud-agent # create wrapper - makeWrapper "${nodejs-14_x}/bin/node" "$out/bin/code-server" \ + makeWrapper "${nodejs-16_x}/bin/node" "$out/bin/code-server" \ --add-flags "$out/libexec/code-server/out/node/entry.js" ''; @@ -249,9 +244,9 @@ in stdenv.mkDerivation rec { code-server is VS Code running on a remote server, accessible through the browser. ''; - homepage = "https://github.com/cdr/code-server"; + homepage = "https://github.com/coder/code-server"; license = licenses.mit; - maintainers = with maintainers; [ offline ]; + maintainers = with maintainers; [ offline henkery ]; platforms = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" ]; }; } |
