Skip to content

Instantly share code, notes, and snippets.

@sonowz
Created February 9, 2020 01:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sonowz/d70b03177c344f4bbbc674de5e5bb937 to your computer and use it in GitHub Desktop.
Save sonowz/d70b03177c344f4bbbc674de5e5bb937 to your computer and use it in GitHub Desktop.
Fix vscode remote error when doing SSH into NixOS machine
with import <nixpkgs> {};
let
pname = "fix-vscode-remote";
script = pkgs.writeShellScriptBin pname ''
if [ -z "$1" ]; then
echo "Please specify username."
exit 1
fi
VSCODE_DIR="/home/$1/.vscode-server/bin"
SCRIPT_DIR="$(dirname $0)"
for versiondir in $VSCODE_DIR/*/; do
rm "$versiondir/node"
ln -s "$SCRIPT_DIR/node" "$versiondir/node"
done
'';
in
{}:
stdenv.mkDerivation rec {
name = pname;
nodePackage = nodejs-12_x; # This is vscode runtime
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 ];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment