From 01dd4610f8aa23df5e80e7daf579797013e5d1c4 Mon Sep 17 00:00:00 2001 From: GGG Date: Wed, 17 Aug 2022 10:12:43 -0300 Subject: [PATCH] dotnetCorePackages.combinePackages: refactor This refactors the combinePackages function to properly combine the different .NET versions as the previous version was copying already wrapped binary which wasn't pointing to the combined directories' binary and it also wasn't linking the /sdk-manifests directory. A few other miscellaneous files like LICENSE.txt, nix-support dir and ThirdPartyNotices.txt weren't being copied either which resulted in an incomplete .NET installation in the combined directory. The passthrough.icu property was also not being set which resulted in us being unable to use the result of this function in buildDotnetModule. --- .../compilers/dotnet/combine-packages.nix | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/pkgs/development/compilers/dotnet/combine-packages.nix b/pkgs/development/compilers/dotnet/combine-packages.nix index c99af4e62ae5..4baa53db35f0 100644 --- a/pkgs/development/compilers/dotnet/combine-packages.nix +++ b/pkgs/development/compilers/dotnet/combine-packages.nix @@ -1,8 +1,13 @@ packages: -{ buildEnv, lib }: +{ buildEnv, makeWrapper, lib }: +# TODO: Rethink how we determine and/or get the CLI. +# Possible options raised in #187118: +# 1. A separate argument for the CLI (as suggested by IvarWithoutBones +# 2. Use the highest version SDK for the CLI (as suggested by GGG) +# 3. Something else? let cli = builtins.head packages; in -assert lib.assertMsg ((builtins.length packages) != 0) +assert lib.assertMsg ((builtins.length packages) < 1) ''You must include at least one package, e.g `with dotnetCorePackages; combinePackages [ sdk_3_1 aspnetcore_5_0 @@ -10,11 +15,20 @@ assert lib.assertMsg ((builtins.length packages) != 0) buildEnv { name = "dotnet-core-combined"; paths = packages; - pathsToLink = [ "/host" "/packs" "/sdk" "/shared" "/templates" ]; + pathsToLink = [ "/host" "/packs" "/sdk" "/sdk-manifests" "/shared" "/templates" ]; ignoreCollisions = true; + nativeBuildInputs = [ + makeWrapper + ]; postBuild = '' - cp ${cli}/dotnet $out/dotnet + cp -R ${cli}/{dotnet,LICENSE.txt,nix-support,ThirdPartyNotices.txt} $out/ + mkdir $out/bin - ln -s $out/dotnet $out/bin/ + ln -s $out/dotnet $out/bin/dotnet + wrapProgram $out/bin/dotnet \ + --prefix LD_LIBRARY_PATH : ${cli.icu}/lib ''; + passthru = { + inherit (cli) icu packages; + }; }