Skip to content

Instantly share code, notes, and snippets.

@ivan
Last active May 29, 2022 00:54
Show Gist options
  • Save ivan/4728f8ef9af8db43cd2bd9194b687e9b to your computer and use it in GitHub Desktop.
Save ivan/4728f8ef9af8db43cd2bd9194b687e9b to your computer and use it in GitHub Desktop.
Fix vscode server for NixOS
# 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 ];
}
#!/bin/sh
set -eu -o pipefail -o verbose
cd ~/bin
nix-build fix-vscode-server-binaries.nix
./result/bin/fix-vscode-server-binaries
@Enzime
Copy link

Enzime commented Mar 14, 2022

I've made a PR to fix this for those using the remote-ssh extension from Nixpkgs :) NixOS/nixpkgs#163797

@ivan
Copy link
Author

ivan commented Apr 9, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment