77 openssl ,
88 libz ,
99 glibc ,
10+ libkrb5 ,
1011 coreutils ,
12+ jq ,
13+ patchelf ,
1114} :
1215let
1316 extInfo = (
@@ -40,16 +43,18 @@ vscode-utils.buildVscodeMarketplaceExtension {
4043 inherit ( extInfo ) hash arch ;
4144 } ;
4245
43- nativeBuildInputs = lib . optionals stdenv . hostPlatform . isLinux [ autoPatchelfHook ] ;
46+ nativeBuildInputs = lib . optionals stdenv . hostPlatform . isLinux [
47+ autoPatchelfHook
48+ jq
49+ patchelf
50+ ] ;
4451 buildInputs = lib . optionals stdenv . hostPlatform . isLinux [
45- ( lib . getLib stdenv . cc . cc ) # libstdc++.so.6
4652 ( lib . getLib glibc ) # libgcc_s.so.1
47- ( lib . getLib libz ) # libz.so.1
48- ] ;
49- runtimeDependencies = lib . optionals stdenv . hostPlatform . isLinux [
50- ( lib . getLib openssl ) # libopenssl.so.3
5153 ( lib . getLib icu ) # libicui18n.so libicuuc.so
54+ ( lib . getLib libkrb5 ) # libgssapi_krb5.so
5255 ( lib . getLib libz ) # libz.so.1
56+ ( lib . getLib openssl ) # libopenssl.so.3
57+ ( lib . getLib stdenv . cc . cc ) # libstdc++.so.6
5358 ] ;
5459
5560 postPatch = ''
@@ -59,17 +64,73 @@ vscode-utils.buildVscodeMarketplaceExtension {
5964
6065 preFixup = ''
6166 (
67+ set -euo pipefail
6268 shopt -s globstar
6369 shopt -s dotglob
70+
71+ # Fix all binaries.
6472 for file in "$out"/**/*; do
65- if [[ ! -f "$file" || "$file" == *.so || "$file" == *.dylib ]] ||
73+ if [[ ! -f "$file" || "$file" == *.so || "$file" == *.a || "$file" == *. dylib ]] ||
6674 (! isELF "$file" && ! isMachO "$file"); then
6775 continue
6876 fi
6977
7078 echo Making "$file" executable...
7179 chmod +x "$file"
80+
81+ ${ lib . optionalString stdenv . hostPlatform . isLinux ''
82+ # Add .NET deps if it is an apphost.
83+ if grep 'You must install .NET to run this application.' "$file" > /dev/null; then
84+ echo "Adding .NET needed libraries to: $file"
85+ patchelf \
86+ --add-needed libicui18n.so \
87+ --add-needed libicuuc.so \
88+ --add-needed libgssapi_krb5.so \
89+ --add-needed libssl.so \
90+ "$file"
91+ fi
92+ '' }
7293 done
94+
95+ ${ lib . optionalString stdenv . hostPlatform . isLinux ''
96+ # Add the ICU libraries as needed to the globalization DLLs.
97+ for file in "$out"/**/{libcoreclr.so,*System.Globalization.Native.so}; do
98+ echo "Adding ICU libraries to: $file"
99+ patchelf \
100+ --add-needed libicui18n.so \
101+ --add-needed libicuuc.so \
102+ "$file"
103+ done
104+
105+ # Add the Kerberos libraries as needed to the native security DLL.
106+ for file in "$out"/**/*System.Net.Security.Native.so; do
107+ echo "Adding Kerberos libraries to: $file"
108+ patchelf \
109+ --add-needed libgssapi_krb5.so \
110+ "$file"
111+ done
112+
113+ # Add the OpenSSL libraries as needed to the OpenSSL native security DLL.
114+ for file in "$out"/**/*System.Security.Cryptography.Native.OpenSsl.so; do
115+ echo "Adding OpenSSL libraries to: $file"
116+ patchelf \
117+ --add-needed libssl.so \
118+ "$file"
119+ done
120+
121+ # Add the needed binaries to the apphost binaries.
122+ for file in $(jq -r '.runtimeDependencies | map(select(.binaries != null) | .installPath + "/" + .binaries[]) | sort | unique | map(sub("/\\./"; "/")) | .[]' < "$out"/share/vscode/extensions/ms-dotnettools.csharp/package.json); do
123+ [ -f "$out"/share/vscode/extensions/ms-dotnettools.csharp/"$file" ] || continue
124+
125+ echo "Adding .NET needed libraries to: $out/share/vscode/extensions/ms-dotnettools.csharp/$file"
126+ patchelf \
127+ --add-needed libicui18n.so \
128+ --add-needed libicuuc.so \
129+ --add-needed libgssapi_krb5.so \
130+ --add-needed libssl.so \
131+ "$out"/share/vscode/extensions/ms-dotnettools.csharp/"$file"
132+ done
133+ '' }
73134 )
74135 '' ;
75136
@@ -78,7 +139,7 @@ vscode-utils.buildVscodeMarketplaceExtension {
78139 meta = {
79140 description = "Official C# support for Visual Studio Code" ;
80141 homepage = "https://github.com/dotnet/vscode-csharp" ;
81- license = lib . licenses . mit ;
142+ license = lib . licenses . unfree ;
82143 maintainers = with lib . maintainers ; [ ggg ] ;
83144 platforms = [
84145 "x86_64-linux"
0 commit comments