about summary refs log tree commit diff
path: root/pkgs/servers/code-server
diff options
context:
space:
mode:
authorPol Dellaiera <pol.dellaiera@protonmail.com>2023-06-27 23:04:28 +0200
committerGitHub <noreply@github.com>2023-06-27 23:04:28 +0200
commita835a56b54a03628557c333c1fbd5a7221301c61 (patch)
tree993d7433105fd88495e03c0b673451ad13b809a8 /pkgs/servers/code-server
parentf7d2276f86bf14820924f8dfffdfed1db41e3511 (diff)
code-server: restore previous patch (#240194)
Also add a note about the `commit` value and how to get it.
Diffstat (limited to 'pkgs/servers/code-server')
-rw-r--r--pkgs/servers/code-server/build-vscode-nogit.patch27
-rw-r--r--pkgs/servers/code-server/default.nix24
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 335349e4651a3..ec726c68d438d 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 e7890f8802f06..b5fe5a0675d8e 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 <git-rev>` where <git-rev> 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 = ''