blob: 63e351f69b4a3cc7bba011bf03dd7549d980b645 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
{ lib
, nixosTests
, vscode-utils
, useLocalExtensions ? false
}:
# Note that useLocalExtensions requires that vscode-server is not running
# on host. If it is, you'll need to remove $HOME/.vscode-server,
# and redo the install by running "Connect to host" on client
let
inherit (vscode-utils) buildVscodeMarketplaceExtension;
# As VS Code executes this code on the remote machine
# we test to see if we can build Node from Nixpkgs
# otherwise we check if the globally installed Node
# is usable.
patch = ''
# Use Node from nixpkgs for NixOS hosts
#
serverDir="$HOME/.vscode-server/bin/$COMMIT_ID"
serverNode="$serverDir/node"
echo "VS Code Node: $serverNode"
# Check if Node included with VS Code Server runs
if ! nodeVersion=$($serverNode -v); then
echo "VS Code Node Version: $nodeVersion"
if ! nix-build "<nixpkgs>" -A patchelf --out-link "$serverDir/patchelf" || ! "$serverDir/patchelf/bin/patchelf" --version; then
echo "Failed to get patchelf from nixpkgs"
fi
if [ -e $serverNode.orig ]; then
cp $serverNode.orig $serverNode
else
cp $serverNode $serverNode.orig
fi
if ! nix-build "<nixpkgs>" -A bintools --out-link $serverDir/bintools; then
echo "Failed to build bintools from nixpkgs"
fi
INTERPRETER=$(cat $serverDir/bintools/nix-support/dynamic-linker)
echo "Interpreter from bintools: $INTERPRETER"
if ! nix-build "<nixpkgs>" -A stdenv.cc.cc.lib --out-link $serverDir/cc; then
echo "Failed to build stdenv.cc.cc.lib from nixpkgs"
fi
if ! $serverDir/patchelf/bin/patchelf --set-interpreter $INTERPRETER --set-rpath $serverDir/cc-lib/lib $serverNode; then
echo "Failed to patch Node binary"
fi
rm "$serverDir/patchelf"
fi
nodeVersion=$($serverNode -v)
echo "VS Code Node Version: $nodeVersion"
if ! nodeVersion=$($serverNode -v); then
echo "Unable to fix Node binary, quitting"
fail_with_exitcode ''${o.InstallExitCode.ServerTransferFailed}
fi
${lib.optionalString useLocalExtensions ''
# Use local extensions
if [ -d $HOME/.vscode/extensions ]; then
if [ -e $HOME/.vscode-server/extensions ]; then
mv $HOME/.vscode-server/extensions $HOME/.vscode-server/extensions.bak
fi
mkdir -p $HOME/.vscode-server
ln -s $HOME/.vscode/extensions $HOME/.vscode-server/extensions
fi
''}
#
# Start the server
'';
in
buildVscodeMarketplaceExtension {
mktplcRef = {
name = "remote-ssh";
publisher = "ms-vscode-remote";
version = "0.78.0";
hash = "sha256-vd+9d86Z8429QpQVCZm8gtiJDcMpD++aiFVwvCrPg5w=";
};
postPatch = ''
substituteInPlace "out/extension.js" \
--replace '# Start the server\n' '${patch}'
'';
passthru.tests = { inherit (nixosTests) vscode-remote-ssh; };
meta = {
description = "Use any remote machine with a SSH server as your development environment.";
license = lib.licenses.unfree;
maintainers = [ lib.maintainers.tbenst ];
};
}
|