From a835a56b54a03628557c333c1fbd5a7221301c61 Mon Sep 17 00:00:00 2001 From: Pol Dellaiera Date: Tue, 27 Jun 2023 23:04:28 +0200 Subject: [PATCH] code-server: restore previous patch (#240194) Also add a note about the `commit` value and how to get it. --- .../code-server/build-vscode-nogit.patch | 27 ++++--------------- pkgs/servers/code-server/default.nix | 24 +++++++++++++++++ 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/pkgs/servers/code-server/build-vscode-nogit.patch b/pkgs/servers/code-server/build-vscode-nogit.patch index 335349e4651a..ec726c68d438 100644 --- a/pkgs/servers/code-server/build-vscode-nogit.patch +++ b/pkgs/servers/code-server/build-vscode-nogit.patch @@ -1,15 +1,8 @@ diff --git a/ci/build/build-vscode.sh b/ci/build/build-vscode.sh -index a72549fb..b1b6074b 100755 +index a72549fb..3aed1ad5 100755 --- a/ci/build/build-vscode.sh +++ b/ci/build/build-vscode.sh -@@ -52,13 +52,12 @@ main() { - # since Code tries to get the commit from the `.git` directory which will fail - # as it is a submodule. - export BUILD_SOURCEVERSION -- BUILD_SOURCEVERSION=$(git rev-parse HEAD) -+ BUILD_SOURCEVERSION=none - - # Add the date, our name, links, and enable telemetry (this just makes +@@ -58,7 +58,6 @@ main() { # telemetry available; telemetry can still be disabled by flag or setting). # This needs to be done before building as Code will read this file and embed # it into the client-side code. @@ -17,21 +10,11 @@ index a72549fb..b1b6074b 100755 cp product.json product.original.json # Since jq has no inline edit. jq --slurp '.[0] * .[1]' product.original.json <( cat << EOF -@@ -105,17 +104,12 @@ EOF +@@ -105,7 +104,6 @@ EOF # Reset so if you develop after building you will not be stuck with the wrong # commit (the dev client will use `oss-dev` but the dev server will still use # product.json which will have `stable-$commit`). - git checkout product.json - + popd - - pushd lib/vscode-reh-web-linux-x64 - # Make sure Code took the version we set in the environment variable. Not - # having a version will break display languages. -- if ! jq -e .commit product.json; then -- echo "'commit' is missing from product.json" -- exit 1 -- fi - popd - - # These provide a `code-server` command in the integrated terminal to open \ No newline at end of file + diff --git a/pkgs/servers/code-server/default.nix b/pkgs/servers/code-server/default.nix index e7890f8802f0..b5fe5a0675d8 100644 --- a/pkgs/servers/code-server/default.nix +++ b/pkgs/servers/code-server/default.nix @@ -54,6 +54,24 @@ let sed -i 's/${version}/${esbuild'.version}/g' ${path}/node_modules/esbuild/lib/main.js ln -s -f ${esbuild'}/bin/esbuild ${path}/node_modules/esbuild/bin/esbuild ''; + + # Comment from @code-asher, the code-server maintainer + # See https://github.com/NixOS/nixpkgs/pull/240001#discussion_r1244303617 + # + # If the commit is missing it will break display languages (Japanese, Spanish, + # etc). For some reason VS Code has a hard dependency on the commit being set + # for that functionality. + # The commit is also used in cache busting. Without the commit you could run + # into issues where the browser is loading old versions of assets from the + # cache. + # Lastly, it can be helpful for the commit to be accurate in bug reports + # especially when they are built outside of our CI as sometimes the version + # numbers can be unreliable (since they are arbitrarily provided). + # + # To compute the commit when upgrading this derivation, do: + # `$ git rev-parse ` where is the git revision of the `src` + # Example: `$ git rev-parse v4.14.1` + commit = "5c199629305a0b935b4388b7db549f77eae82b5a"; in stdenv.mkDerivation (finalAttrs: { pname = "code-server"; @@ -129,6 +147,12 @@ stdenv.mkDerivation (finalAttrs: { export HOME=$PWD patchShebangs ./ci + + # inject git commit + substituteInPlace ./ci/build/build-vscode.sh \ + --replace '$(git rev-parse HEAD)' "${commit}" + substituteInPlace ./ci/build/build-release.sh \ + --replace '$(git rev-parse HEAD)' "${commit}" ''; configurePhase = ''