···1-# Baseed on previous attempts:
2# - <https://github.com/msteen/nixos-vsliveshare/blob/master/pkgs/vsliveshare/default.nix>
3# - <https://github.com/NixOS/nixpkgs/issues/41189>
4-{ lib, gccStdenv, vscode-utils, autoPatchelfHook, bash, file, makeWrapper, dotnet-sdk_3
5-, curl, gcc, icu, libkrb5, libsecret, libunwind, libX11, lttng-ust, openssl, util-linux, zlib
6-, desktop-file-utils, xprop
07}:
89with lib;
···37 mktplcRef = {
38 name = "vsliveshare";
39 publisher = "ms-vsliveshare";
40- version = "1.0.2902";
41- sha256 = "0fx2vi0wxamcwqcgcx7wpg8hi7f1c2pibrmd2qy2whilpsv3gzmb";
42 };
43-}).overrideAttrs(attrs: {
44- buildInputs = attrs.buildInputs ++ libs ++ [ autoPatchelfHook bash file makeWrapper ];
0000004546 # Using a patch file won't work, because the file changes too often, causing the patch to fail on most updates.
47 # Rather than patching the calls to functions, we modify the functions to return what we want,
···5758 # Fix extension attempting to write to 'modifiedInternalSettings.json'.
59 # Move this write to the tmp directory indexed by the nix store basename.
60- sed -i \
61- -E -e $'s/path\.resolve\(constants_1\.EXTENSION_ROOT_PATH, \'\.\/modifiedInternalSettings\.json\'\)/path.join\(os.tmpdir(), "'$ext_unique_id'" + "-modifiedInternalSettings.json"\)/g' \
62- out/prod/extension-prod.js
6364 # Fix extension attempting to write to 'vsls-agent.lock'.
65 # Move this write to the tmp directory indexed by the nix store basename.
66- sed -i \
67- -E -e $'s/(Agent_1.getAgentPath\(\) \+ \'.lock\')/path.join\(os.tmpdir(), "'$ext_unique_id'" + "-vsls-agent.lock"\)/g' \
68- out/prod/extension-prod.js
6970- # TODO: Under 'node_modules/@vsliveshare/vscode-launcher-linux' need to hardcode path to 'desktop-file-install'
71- # 'update-desktop-database' and 'xprop'. Might want to wrap the script instead.
00000000072 '';
7374- # Support for the `postInstall` hook was added only in nixos-20.03,
75- # so for backwards compatibility reasons lets not use it yet.
76- installPhase = attrs.installPhase + ''
77- # Support both the new and old directory structure of vscode extensions.
78- if [[ -d $out/ms-vsliveshare.vsliveshare ]]; then
79- cd $out/ms-vsliveshare.vsliveshare
80- elif [[ -d $out/share/vscode/extensions/ms-vsliveshare.vsliveshare ]]; then
81- cd $out/share/vscode/extensions/ms-vsliveshare.vsliveshare
82- else
83- echo "Could not find extension directory 'ms-vsliveshare.vsliveshare'." >&2
84- exit 1
85- fi
8687 bash -s <<ENDSUBSHELL
88 shopt -s extglob
···9899 # The required executables are already copied over,
100 # and the other runtimes won't be used and thus are just a waste of space.
101- rm -r dotnet_modules/exes dotnet_modules/runtimes/!(linux-x64)
102103 # Not all executables and libraries are executable, so make sure that they are.
104- find . -type f ! -executable -exec file {} + | grep -w ELF | cut -d ':' -f1 | xargs -rd'\n' chmod +x
105-106- # Not all scripts are executed by passing them to a shell, so they need to be executable as well.
107- find . -type f -name '*.sh' ! -executable -exec chmod +x {} +
108109 # Lock the extension downloader.
110 touch install-linux.Lock externalDeps-linux.Lock
111 ENDSUBSHELL
112 '';
113114- rpath = makeLibraryPath libs;
115-116 postFixup = ''
117 # We cannot use `wrapProgram`, because it will generate a relative path,
118 # which will break when copying over the files.
119 mv dotnet_modules/vsls-agent{,-wrapped}
120 makeWrapper $PWD/dotnet_modules/vsls-agent{-wrapped,} \
121- --prefix LD_LIBRARY_PATH : "$rpath" \
122 --set LD_PRELOAD $PWD/dotnet_modules/noop-syslog.so \
123 --set DOTNET_ROOT ${dotnet-sdk_3}
124-125- for bn in check-reqs.sh install.sh uninstall.sh; do
126- wrapProgram "$PWD/node_modules/@vsliveshare/vscode-launcher-linux/$bn" \
127- --prefix PATH : "${makeBinPath [desktop-file-utils xprop]}"
128- done
129 '';
130131 meta = {
···1+# Based on previous attempts:
2# - <https://github.com/msteen/nixos-vsliveshare/blob/master/pkgs/vsliveshare/default.nix>
3# - <https://github.com/NixOS/nixpkgs/issues/41189>
4+{ lib, gccStdenv, vscode-utils
5+, jq, autoPatchelfHook, bash, makeWrapper
6+, dotnet-sdk_3, curl, gcc, icu, libkrb5, libsecret, libunwind, libX11, lttng-ust, openssl, util-linux, zlib
7+, desktop-file-utils, xprop, xsel
8}:
910with lib;
···38 mktplcRef = {
39 name = "vsliveshare";
40 publisher = "ms-vsliveshare";
41+ version = "1.0.3912";
42+ sha256 = "1k5yy04q85jjr7hzrv0s7x1m2251kglb038wcvvbs568vpscghi8";
43 };
44+}).overrideAttrs({ nativeBuildInputs ? [], buildInputs ? [], ... }: {
45+ nativeBuildInputs = nativeBuildInputs ++ [
46+ bash
47+ jq
48+ autoPatchelfHook
49+ makeWrapper
50+ ];
51+ buildInputs = buildInputs ++ libs;
5253 # Using a patch file won't work, because the file changes too often, causing the patch to fail on most updates.
54 # Rather than patching the calls to functions, we modify the functions to return what we want,
···6465 # Fix extension attempting to write to 'modifiedInternalSettings.json'.
66 # Move this write to the tmp directory indexed by the nix store basename.
67+ substituteInPlace out/prod/extension-prod.js \
68+ --replace "path.resolve(constants_1.EXTENSION_ROOT_PATH, './modifiedInternalSettings.json')" \
69+ "path.join(os.tmpdir(), '$ext_unique_id-modifiedInternalSettings.json')"
7071 # Fix extension attempting to write to 'vsls-agent.lock'.
72 # Move this write to the tmp directory indexed by the nix store basename.
73+ substituteInPlace out/prod/extension-prod.js \
74+ --replace "path + '.lock'" \
75+ "__webpack_require__('path').join(__webpack_require__('os').tmpdir(), '$ext_unique_id-vsls-agent.lock')"
7677+ # Hardcode executable paths
78+ echo '#!/bin/sh' >node_modules/@vsliveshare/vscode-launcher-linux/check-reqs.sh
79+ substituteInPlace node_modules/@vsliveshare/vscode-launcher-linux/install.sh \
80+ --replace desktop-file-install ${desktop-file-utils}/bin/desktop-file-install
81+ substituteInPlace node_modules/@vsliveshare/vscode-launcher-linux/uninstall.sh \
82+ --replace update-desktop-database ${desktop-file-utils}/bin/update-desktop-database
83+ substituteInPlace node_modules/@vsliveshare/vscode-launcher-linux/vsls-launcher \
84+ --replace /bin/bash ${bash}/bin/bash
85+ substituteInPlace out/prod/extension-prod.js \
86+ --replace xprop ${xprop}/bin/xprop \
87+ --replace "'xsel'" "'${xsel}/bin/xsel'"
88 '';
8990+ postInstall = ''
91+ cd $out/share/vscode/extensions/ms-vsliveshare.vsliveshare
00000000009293 bash -s <<ENDSUBSHELL
94 shopt -s extglob
···104105 # The required executables are already copied over,
106 # and the other runtimes won't be used and thus are just a waste of space.
107+ rm -r dotnet_modules/exes dotnet_modules/runtimes/!(linux-x64|unix)
108109 # Not all executables and libraries are executable, so make sure that they are.
110+ jq <package.json '.executables.linux[]' -r | xargs chmod +x
000111112 # Lock the extension downloader.
113 touch install-linux.Lock externalDeps-linux.Lock
114 ENDSUBSHELL
115 '';
11600117 postFixup = ''
118 # We cannot use `wrapProgram`, because it will generate a relative path,
119 # which will break when copying over the files.
120 mv dotnet_modules/vsls-agent{,-wrapped}
121 makeWrapper $PWD/dotnet_modules/vsls-agent{-wrapped,} \
122+ --prefix LD_LIBRARY_PATH : "${makeLibraryPath libs}" \
123 --set LD_PRELOAD $PWD/dotnet_modules/noop-syslog.so \
124 --set DOTNET_ROOT ${dotnet-sdk_3}
00000125 '';
126127 meta = {