2021-03-06 12:13:26 +00:00
|
|
|
# Based on previous attempts:
|
2020-10-16 09:13:12 +01:00
|
|
|
# - <https://github.com/msteen/nixos-vsliveshare/blob/master/pkgs/vsliveshare/default.nix>
|
|
|
|
# - <https://github.com/NixOS/nixpkgs/issues/41189>
|
2021-03-06 12:13:26 +00:00
|
|
|
{ lib, gccStdenv, vscode-utils
|
|
|
|
, jq, autoPatchelfHook, bash, makeWrapper
|
|
|
|
, dotnet-sdk_3, curl, gcc, icu, libkrb5, libsecret, libunwind, libX11, lttng-ust, openssl, util-linux, zlib
|
|
|
|
, desktop-file-utils, xprop, xsel
|
2020-10-16 09:13:12 +01:00
|
|
|
}:
|
|
|
|
|
|
|
|
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
|
2020-11-24 15:29:28 +00:00
|
|
|
util-linux # libuuid
|
2020-10-16 09:13:12 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
in ((vscode-utils.override { stdenv = gccStdenv; }).buildVscodeMarketplaceExtension {
|
|
|
|
mktplcRef = {
|
|
|
|
name = "vsliveshare";
|
|
|
|
publisher = "ms-vsliveshare";
|
2021-03-14 09:31:02 +00:00
|
|
|
version = "1.0.3968";
|
|
|
|
sha256 = "1nmhkxrlg9blxcqh7a3hl0wc5mkk2p77mn228lvmcirpbk3acsx5";
|
2020-10-16 09:13:12 +01:00
|
|
|
};
|
2021-03-06 12:13:26 +00:00
|
|
|
}).overrideAttrs({ nativeBuildInputs ? [], buildInputs ? [], ... }: {
|
|
|
|
nativeBuildInputs = nativeBuildInputs ++ [
|
|
|
|
bash
|
|
|
|
jq
|
|
|
|
autoPatchelfHook
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
buildInputs = buildInputs ++ libs;
|
2020-10-16 09:13:12 +01:00
|
|
|
|
|
|
|
# Using a patch file won't work, because the file changes too often, causing the patch to fail on most updates.
|
|
|
|
# Rather than patching the calls to functions, we modify the functions to return what we want,
|
|
|
|
# which is less likely to break in the future.
|
|
|
|
postPatch = ''
|
|
|
|
sed -i \
|
|
|
|
-e 's/updateExecutablePermissionsAsync() {/& return;/' \
|
|
|
|
-e 's/isInstallCorrupt(traceSource, manifest) {/& return false;/' \
|
|
|
|
out/prod/extension-prod.js
|
|
|
|
|
|
|
|
declare ext_unique_id
|
|
|
|
ext_unique_id="$(basename "$out")"
|
|
|
|
|
|
|
|
# Fix extension attempting to write to 'modifiedInternalSettings.json'.
|
|
|
|
# Move this write to the tmp directory indexed by the nix store basename.
|
2021-03-06 12:13:26 +00:00
|
|
|
substituteInPlace out/prod/extension-prod.js \
|
|
|
|
--replace "path.resolve(constants_1.EXTENSION_ROOT_PATH, './modifiedInternalSettings.json')" \
|
|
|
|
"path.join(os.tmpdir(), '$ext_unique_id-modifiedInternalSettings.json')"
|
2020-10-16 09:13:12 +01:00
|
|
|
|
|
|
|
# Fix extension attempting to write to 'vsls-agent.lock'.
|
|
|
|
# Move this write to the tmp directory indexed by the nix store basename.
|
2021-03-06 12:13:26 +00:00
|
|
|
substituteInPlace out/prod/extension-prod.js \
|
|
|
|
--replace "path + '.lock'" \
|
|
|
|
"__webpack_require__('path').join(__webpack_require__('os').tmpdir(), '$ext_unique_id-vsls-agent.lock')"
|
|
|
|
|
|
|
|
# Hardcode executable paths
|
|
|
|
echo '#!/bin/sh' >node_modules/@vsliveshare/vscode-launcher-linux/check-reqs.sh
|
|
|
|
substituteInPlace node_modules/@vsliveshare/vscode-launcher-linux/install.sh \
|
|
|
|
--replace desktop-file-install ${desktop-file-utils}/bin/desktop-file-install
|
|
|
|
substituteInPlace node_modules/@vsliveshare/vscode-launcher-linux/uninstall.sh \
|
|
|
|
--replace update-desktop-database ${desktop-file-utils}/bin/update-desktop-database
|
|
|
|
substituteInPlace node_modules/@vsliveshare/vscode-launcher-linux/vsls-launcher \
|
|
|
|
--replace /bin/bash ${bash}/bin/bash
|
|
|
|
substituteInPlace out/prod/extension-prod.js \
|
|
|
|
--replace xprop ${xprop}/bin/xprop \
|
|
|
|
--replace "'xsel'" "'${xsel}/bin/xsel'"
|
2020-10-16 09:13:12 +01:00
|
|
|
'';
|
|
|
|
|
2021-03-06 12:13:26 +00:00
|
|
|
postInstall = ''
|
|
|
|
cd $out/share/vscode/extensions/ms-vsliveshare.vsliveshare
|
2020-10-16 09:13:12 +01:00
|
|
|
|
|
|
|
bash -s <<ENDSUBSHELL
|
|
|
|
shopt -s extglob
|
|
|
|
|
|
|
|
# A workaround to prevent the journal filling up due to diagnostic logging.
|
|
|
|
# See: https://github.com/MicrosoftDocs/live-share/issues/1272
|
|
|
|
# See: https://unix.stackexchange.com/questions/481799/how-to-prevent-a-process-from-writing-to-the-systemd-journal
|
|
|
|
gcc -fPIC -shared -ldl -o dotnet_modules/noop-syslog.so ${./noop-syslog.c}
|
|
|
|
|
|
|
|
# Normally the copying of the right executables is done externally at a later time,
|
|
|
|
# but we want it done at installation time.
|
|
|
|
cp dotnet_modules/exes/linux-x64/* dotnet_modules
|
|
|
|
|
|
|
|
# The required executables are already copied over,
|
|
|
|
# and the other runtimes won't be used and thus are just a waste of space.
|
2021-03-06 12:13:26 +00:00
|
|
|
rm -r dotnet_modules/exes dotnet_modules/runtimes/!(linux-x64|unix)
|
2020-10-16 09:13:12 +01:00
|
|
|
|
|
|
|
# Not all executables and libraries are executable, so make sure that they are.
|
2021-03-06 12:13:26 +00:00
|
|
|
jq <package.json '.executables.linux[]' -r | xargs chmod +x
|
2020-10-16 09:13:12 +01:00
|
|
|
|
|
|
|
# Lock the extension downloader.
|
|
|
|
touch install-linux.Lock externalDeps-linux.Lock
|
|
|
|
ENDSUBSHELL
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
# We cannot use `wrapProgram`, because it will generate a relative path,
|
|
|
|
# which will break when copying over the files.
|
|
|
|
mv dotnet_modules/vsls-agent{,-wrapped}
|
|
|
|
makeWrapper $PWD/dotnet_modules/vsls-agent{-wrapped,} \
|
2021-03-06 12:13:26 +00:00
|
|
|
--prefix LD_LIBRARY_PATH : "${makeLibraryPath libs}" \
|
2020-10-16 09:13:12 +01:00
|
|
|
--set LD_PRELOAD $PWD/dotnet_modules/noop-syslog.so \
|
|
|
|
--set DOTNET_ROOT ${dotnet-sdk_3}
|
|
|
|
'';
|
|
|
|
|
|
|
|
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 = with maintainers; [ jraygauthier ];
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
})
|