From 747c5ca3404241489f9cc27234cdf3844edb5da0 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Thu, 8 Sep 2022 15:48:42 -0300 Subject: [PATCH] dotnet-sdk: patch shared libraries to find icu/libkrb5 --- .../compilers/dotnet/build-dotnet.nix | 52 ++++++++++--------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/pkgs/development/compilers/dotnet/build-dotnet.nix b/pkgs/development/compilers/dotnet/build-dotnet.nix index 37be33c2263c..96713c2055ac 100644 --- a/pkgs/development/compilers/dotnet/build-dotnet.nix +++ b/pkgs/development/compilers/dotnet/build-dotnet.nix @@ -18,6 +18,7 @@ assert if type == "sdk" then packages != null else true; , openssl_1_1 , libuuid , zlib +, libkrb5 , curl , lttng-ust_2_12 }: @@ -41,23 +42,20 @@ stdenv.mkDerivation rec { inherit pname version; # Some of these dependencies are `dlopen()`ed. - rpath = lib.makeLibraryPath ([ - stdenv.cc.cc - zlib - curl - icu - libunwind - libuuid - openssl_1_1 - ] ++ lib.optional stdenv.isLinux lttng-ust_2_12); - nativeBuildInputs = [ makeWrapper ] ++ lib.optional stdenv.isLinux autoPatchelfHook; buildInputs = [ stdenv.cc.cc - ]; + zlib + icu + libkrb5 + # this must be before curl for autoPatchElf to find it + # curl brings in its own openssl + openssl_1_1 + curl + ] ++ lib.optional stdenv.isLinux lttng-ust_2_12; src = fetchurl ( srcs."${stdenv.hostPlatform.system}" or (throw @@ -77,24 +75,30 @@ stdenv.mkDerivation rec { runHook postInstall ''; - postFixup = lib.optionalString stdenv.isLinux '' - patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $out/dotnet - patchelf --set-rpath "${rpath}" $out/dotnet - find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \; - find $out -type f \( -name "apphost" -or -name "createdump" \) -exec patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath '$ORIGIN:${rpath}' {} \; - - wrapProgram $out/bin/dotnet \ - --prefix LD_LIBRARY_PATH : ${icu}/lib - ''; - doInstallCheck = true; installCheckPhase = '' - # Fixes cross - export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1 - $out/bin/dotnet --info ''; + # Tell autoPatchelf about runtime dependencies. + # (postFixup phase is run before autoPatchelfHook.) + postFixup = lib.optionalString stdenv.isLinux '' + patchelf \ + --add-needed libicui18n.so \ + --add-needed libicuuc.so \ + $out/shared/Microsoft.NETCore.App/*/libcoreclr.so \ + $out/shared/Microsoft.NETCore.App/*/*System.Globalization.Native.so \ + $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost + patchelf \ + --add-needed libgssapi_krb5.so \ + $out/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \ + $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost + patchelf \ + --add-needed libssl.so \ + $out/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \ + $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost + ''; + setupHook = writeText "dotnet-setup-hook" '' if [ ! -w "$HOME" ]; then export HOME=$(mktemp -d) # Dotnet expects a writable home directory for its configuration files