-
-
Save ivan/4728f8ef9af8db43cd2bd9194b687e9b to your computer and use it in GitHub Desktop.
| # Based on https://gist.github.com/sonowz/d70b03177c344f4bbbc674de5e5bb937 | |
| with import <nixpkgs> {}; | |
| let | |
| pname = "fix-vscode-server-binaries"; | |
| script = pkgs.writeShellScriptBin pname '' | |
| set -eu -o pipefail | |
| SCRIPT_DIR="$(dirname -- "$(readlink -f -- "$0")")" | |
| interpreter=$(patchelf --print-interpreter /run/current-system/sw/bin/sh) | |
| for i in ~/.vscode-server/cli/servers/*/server/; do | |
| ls -l "$i/node.orig" || mv -fT "$i/node" "$i/node.orig" | |
| ln -sfT "$SCRIPT_DIR/node" "$i/node" | |
| done | |
| # Replace the vscode-downloaded ripgrep binary with our faster LTO build | |
| for i in ~/.vscode-server/cli/servers/*/server/node_modules/@vscode/ripgrep/bin/rg; do | |
| ln -sfT /run/current-system/sw/bin/rg "$i" | |
| done | |
| # Patch the C++ and Flow tools to run on NixOS. | |
| for i in ~/.vscode-server/extensions/ms-vscode.*/bin/cpptools*; do | |
| patchelf --set-interpreter "$interpreter" "$i" | |
| done | |
| ''; | |
| in | |
| {}: | |
| stdenv.mkDerivation rec { | |
| name = pname; | |
| nodePackage = nodejs_20; | |
| src = ./.; | |
| installPhase = '' | |
| mkdir -p $out/bin | |
| cp ${script}/bin/${pname} $out/bin/${pname} | |
| cp ${nodePackage}/bin/node $out/bin/node | |
| chmod +x $out/bin/${pname} | |
| ''; | |
| buildInputs = [ script nodePackage ]; | |
| } |
| #!/bin/sh | |
| set -eu -o pipefail -o verbose | |
| cd ~/bin | |
| nix-build fix-vscode-server-binaries.nix | |
| ./result/bin/fix-vscode-server-binaries |
My code no longer works (patchelf to take libstdc++.so.6 from node 16) and for vscode 1.57, I've started symlinking NixOS's node 14 binary. Thanks to samuela/nixos-fix-vscode-remote@f105e97 for the hint.
Updated the fix here to using nix-build to get node 14, based on https://gist.github.com/sonowz/d70b03177c344f4bbbc674de5e5bb937
I've made a PR to fix this for those using the remote-ssh extension from Nixpkgs :) NixOS/nixpkgs#163797
Updated the fix here to use node 16.
Using node 14 with a vscode 1.66 client appears to work at first, but actually causes the node ... bootstrap-fork process to use > 100% CPU forever.
Updated again for the new ~/.vscode-server paths, and for node 20.
Note that vscode-remote immediately tries to run the server it downloads and deletes the directory if it fails (microsoft/vscode-remote-release#9855), so you need to race vscode-remote several times to successfully patch the server.
@grahamc suggested:
https://twitter.com/grhmc/status/1357425019580801026?s=20