VS Code Live Share extension
# Baseed on previous attempts of others: https://github.com/NixOS/nixpkgs/issues/41189 | |
{ lib, vscode-utils, autoPatchelfHook, bash, file, makeWrapper, dotnet-sdk | |
, curl, gcc, icu, libkrb5, libsecret, libunwind, libX11, lttng-ust, openssl, utillinux, zlib | |
, enableDiagnosticsWorkaround ? false, gccStdenv | |
}: | |
with lib; | |
let | |
# https://docs.microsoft.com/en-us/visualstudio/liveshare/reference/linux#install-prerequisites-manually | |
libs = [ | |
# .NET Core | |
openssl | |
libkrb5 | |
zlib | |
icu | |
# Credential Storage | |
libsecret | |
# NodeJS | |
libX11 | |
# https://github.com/flathub/com.visualstudio.code.oss/issues/11#issuecomment-392709170 | |
libunwind | |
lttng-ust | |
curl | |
# General | |
gcc.cc.lib | |
utillinux # libuuid | |
]; | |
vscode-utils' = if enableDiagnosticsWorkaround | |
then vscode-utils.override { stdenv = gccStdenv; } | |
else vscode-utils; | |
in (vscode-utils'.buildVscodeMarketplaceExtension { | |
mktplcRef = { | |
name = "vsliveshare"; | |
publisher = "ms-vsliveshare"; | |
version = "0.3.1013"; | |
sha256 = "1a730mpv2jz6ksqrbx13ph33109plx234jrdf5qy2dm2w5cbhvm5"; | |
}; | |
}).overrideAttrs(attrs: { | |
patches = [ ./extension.js.patch ]; | |
buildInputs = attrs.buildInputs ++ libs ++ [ autoPatchelfHook bash file makeWrapper ]; | |
installPhase = attrs.installPhase + '' | |
runHook postInstall | |
''; | |
postInstall = '' | |
bash -s <<ENDSUBSHELL | |
shopt -s extglob | |
cd $out/share/vscode/extensions/ms-vsliveshare.vsliveshare | |
# A workaround to prevent the journal filling up due to diagnostic logging. | |
${optionalString enableDiagnosticsWorkaround '' | |
gcc -fPIC -shared -ldl -o dotnet_modules/noop-syslog.so ${./noop-syslog.c} | |
''} | |
# Normally the copying of the right executables and libraries is done externally at a later time, | |
# but we want it done at installation time. | |
# FIXME: Surely there is a better way than copying over the shared .NET libraries. | |
cp \ | |
${dotnet-sdk}/shared/Microsoft.NETCore.App/*/* \ | |
dotnet_modules/runtimes/linux-x64/!(native) \ | |
dotnet_modules/runtimes/linux-x64/native/* \ | |
dotnet_modules/runtimes/unix/lib/netstandard1.3/* \ | |
dotnet_modules | |
# Those we need are already copied over, the rest is just a waste of space. | |
rm -r dotnet_modules/runtimes | |
# Not all executables and libraries are executable, so make sure that they are. | |
find . -type f ! -executable -exec file {} + | grep -w ELF | cut -d ':' -f1 | tr '\n' '\0' | xargs -0r -n1 chmod +x | |
# Not all scripts are executed by passing them to a shell, so they need to be executable as well. | |
find . -type f -name '*.sh' ! -executable -exec chmod +x {} + | |
# Lock the extension downloader. | |
touch install-linux.Lock externalDeps-linux.Lock | |
ENDSUBSHELL | |
''; | |
rpath = makeLibraryPath libs; | |
postFixup = '' | |
root=$out/share/vscode/extensions/ms-vsliveshare.vsliveshare | |
# We cannot use `wrapProgram`, because it will generate a relative path, | |
# which breaks our workaround that makes the extension directory writable. | |
mv $root/dotnet_modules/vsls-agent{,-wrapped} | |
makeWrapper $root/dotnet_modules/vsls-agent{-wrapped,} \ | |
--prefix LD_LIBRARY_PATH : "$rpath" ${optionalString enableDiagnosticsWorkaround ''\ | |
--set LD_PRELOAD "$root/dotnet_modules/noop-syslog.so" | |
''} | |
''; | |
meta = { | |
description = "Live Share lets you achieve greater confidence at speed by streamlining collaborative editing, debugging, and more in real-time during development"; | |
homepage = https://aka.ms/vsls-docs; | |
license = licenses.unfree; | |
maintainers = [ maintainers.msteen ]; | |
platforms = [ "x86_64-linux" ]; | |
}; | |
}) |
--- a/out/src/extension.js | |
+++ b/out/src/extension.js | |
@@ -268,18 +268,7 @@ | |
activationEvent.markTime(telemetryStrings_1.TelemetryPropertyNames.EXTENSION_ACTIVATION_COMPAT_CHECK_COMPLETE); | |
await extensionUtil_1.ExtensionUtil.InitAsync(context); | |
const liveShareExtension = vscode.extensions.getExtension('ms-vsliveshare.vsliveshare'); | |
- const installationResult = await downloader_1.ExternalDownloader.ensureRuntimeDependenciesAsync(liveShareExtension); | |
- const isExtensionUpdated = abTestsUtil_1.isExtensionBeingUpdated(); | |
- activationEvent.addProperty(telemetryStrings_1.TelemetryPropertyNames.IS_EXTENSION_BEING_UPDATED, isExtensionUpdated); | |
- const isExtensionPackCandidatePresent = extensionUtil_1.ExtensionUtil.isExtensionPackCandidatePresent(); | |
- activationEvent.addProperty(telemetryStrings_1.TelemetryPropertyNames.IS_EXTENSION_PACK_CANDIDATE_PRESENT, isExtensionPackCandidatePresent); | |
- // failed to install dependencies | |
- if (installationResult === downloader_1.EnsureRuntimeDependenciesResult.Failure) { | |
- activationEvent.end(telemetry_1.TelemetryResult.UserFailure, 'Extension activation failed - download runtime dependencies.'); | |
- vscode.window.showErrorMessage(`${config.get(config.Key.name)} was unable to download needed dependencies to finish installation. Ensure you have network connectivity and restart VS Code to retry.`); | |
- return; | |
- } | |
- else if ((installationResult === downloader_1.EnsureRuntimeDependenciesResult.Success) && !isExtensionUpdated && isFirstActivation) { | |
+ if (isFirstActivation) { | |
// Show the welcome notification on the first installation | |
const isSelected = (Math.random() <= 0.5); | |
activationEvent.addProperty(telemetryStrings_1.TelemetryPropertyNames.INITIAL_INSTALL_INFO_PAGE_EXPERIMENT_OPEN_BY_DEFAULT, isSelected); | |
@@ -287,7 +276,6 @@ | |
const didShow = (isSelected && !isExtensionPackCandidatePresent) ? await welcomePageUtil_1.showWelcomePage(welcomePageUtil_1.WelcomePageSource.Install) : await welcomePageUtil_1.showWelcomeNotification(); | |
activationEvent.addProperty(telemetryStrings_1.TelemetryPropertyNames.SHOWED_INITIAL_INSTALL_INFO_PAGE, didShow); | |
} | |
- await extensionUtil_1.ExtensionUtil.updateExecutablePermissionsAsync(); | |
await launcher_1.Launcher.setup(false, !(await downloader_1.installFileExistsAsync())); | |
activationEvent.markTime(telemetryStrings_1.TelemetryPropertyNames.EXTENSION_ACTIVATION_LAUNCHER_SETUP_COMPLETE); | |
const rpcClient = new service_1.RPCClient(); | |
@@ -427,15 +415,7 @@ | |
activationAgentEvent.end(telemetry_1.TelemetryResult.Success, 'Agent activation success.'); | |
} | |
catch (e) { | |
- let errorMessage; | |
- if (await downloader_1.isInstallCorrupt(traceSource_1.traceSource)) { | |
- errorMessage = 'An update or installation of VS Live Share failed due to a corrupted download. ' + | |
- 'Please uninstall and reinstall the extension to resolve. ' + | |
- 'See https://aka.ms/vsls-corrupted-install for more details.'; | |
- } | |
- else { | |
- errorMessage = e.message; | |
- } | |
+ let errorMessage = e.message; | |
const telemetryMessage = 'Agent activation failed. ' + errorMessage; | |
activationAgentEvent.end(telemetry_1.TelemetryResult.Failure, telemetryMessage); | |
extensionTelemetry_1.ExtensionTelemetry.sendActivateAgentAsyncFault(telemetry_1.FaultType.Error, telemetryMessage, e, activationAgentEvent); |
void syslog(int priority, const char *format, ...) { } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment