Last active
May 29, 2022 00:54
-
-
Save ivan/4728f8ef9af8db43cd2bd9194b687e9b to your computer and use it in GitHub Desktop.
Fix vscode server for NixOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/bin/*; do | |
ln -sfT "$SCRIPT_DIR/node" "$i/node" | |
done | |
# Replace the vscode-downloaded ripgrep binary with our faster LTO build | |
for i in ~/.vscode-server/bin/*/node_modules/vscode-ripgrep/bin/rg; do | |
ln -sfT /run/current-system/sw/bin/rg "$i" | |
done | |
# Patch the C++ 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-16_x; | |
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 ]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -eu -o pipefail -o verbose | |
cd ~/bin | |
nix-build fix-vscode-server-binaries.nix | |
./result/bin/fix-vscode-server-binaries |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.