dotnet: move dotnet_root to $out/share/dotnet

This commit is contained in:
David McFarland 2024-10-01 22:14:39 -03:00
parent ddd08e404f
commit 42d69ab59a
12 changed files with 57 additions and 46 deletions

View File

@ -724,6 +724,11 @@
reference the underlying dotnet distribution (DOTNET_ROOT) you should use e.g. reference the underlying dotnet distribution (DOTNET_ROOT) you should use e.g.
`dotnet-runtime.unwrapped`. `dotnet-runtime.unwrapped`.
- The root of dotnet distribution packages (DOTNET_ROOT) is now under e.g.
`${dotnet-sdk.unwrapped}/share/dotnet` instead of directly in the package
root. This is consistent with packaging guidelines and more friendly for FHS
environments.
## Other Notable Changes {#sec-release-24.11-notable-changes} ## Other Notable Changes {#sec-release-24.11-notable-changes}
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

View File

@ -44,10 +44,10 @@ dotnetFromEnv'
# if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime # if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$wrapperPath") dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$wrapperPath")
dotnetRootFlagsArray+=("--run" "$dotnetFromEnvScript") dotnetRootFlagsArray+=("--run" "$dotnetFromEnvScript")
dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime") dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$dotnetRuntime/bin") dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$dotnetRuntime/bin")
else else
dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime") dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
dotnetRootFlagsArray+=("--prefix" "PATH" ":" "$dotnetRuntime/bin") dotnetRootFlagsArray+=("--prefix" "PATH" ":" "$dotnetRuntime/bin")
fi fi
fi fi

View File

@ -32,7 +32,7 @@
let let
dyalogHome = "$out/lib/dyalog"; dyalogHome = "$out/lib/dyalog";
makeWrapperArgs = lib.optional dotnetSupport "--set DOTNET_ROOT ${dotnet-sdk_8.unwrapped}"; makeWrapperArgs = lib.optional dotnetSupport "--set DOTNET_ROOT ${dotnet-sdk_8.unwrapped}/share/dotnet";
licenseUrl = "https://www.dyalog.com/uploads/documents/Developer_Software_Licence.pdf"; licenseUrl = "https://www.dyalog.com/uploads/documents/Developer_Software_Licence.pdf";

View File

@ -72,7 +72,7 @@ mkPackage rec {
# The provided libhostfxr.dylib is for x86_64-darwin, so we remove it # The provided libhostfxr.dylib is for x86_64-darwin, so we remove it
rm artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/libhostfxr.dylib rm artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/libhostfxr.dylib
ln -s $(find ${dotnet-sdk.unwrapped} -name libhostfxr${sharedLibrary}) artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/ ln -s $(find ${dotnet-sdk.unwrapped}/share/dotnet -name libhostfxr${sharedLibrary}) artifacts/mono-msbuild/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/
# overwrite the file # overwrite the file
echo "#!${stdenv.shell}" > eng/common/dotnet-install.sh echo "#!${stdenv.shell}" > eng/common/dotnet-install.sh
@ -82,7 +82,7 @@ mkPackage rec {
echo "#!${stdenv.shell}" > mono/build/extract_and_copy_hostfxr.sh echo "#!${stdenv.shell}" > mono/build/extract_and_copy_hostfxr.sh
mkdir -p mono/dotnet-overlay/msbuild-bin mkdir -p mono/dotnet-overlay/msbuild-bin
cp ${dotnet-sdk.unwrapped}/sdk/*/{Microsoft.NETCoreSdk.BundledVersions.props,RuntimeIdentifierGraph.json} mono/dotnet-overlay/msbuild-bin cp ${dotnet-sdk.unwrapped}/share/dotnet/sdk/*/{Microsoft.NETCoreSdk.BundledVersions.props,RuntimeIdentifierGraph.json} mono/dotnet-overlay/msbuild-bin
# DisableNerdbankVersioning https://gitter.im/Microsoft/msbuild/archives/2018/06/27?at=5b33dbc4ce3b0f268d489bfa # DisableNerdbankVersioning https://gitter.im/Microsoft/msbuild/archives/2018/06/27?at=5b33dbc4ce3b0f268d489bfa
# TODO there are some (many?) failing tests # TODO there are some (many?) failing tests
@ -99,7 +99,7 @@ mkPackage rec {
--set-default MONO_GC_PARAMS "nursery-size=64m" \ --set-default MONO_GC_PARAMS "nursery-size=64m" \
--add-flags "$out/lib/mono/msbuild/15.0/bin/MSBuild.dll" --add-flags "$out/lib/mono/msbuild/15.0/bin/MSBuild.dll"
ln -s $(find ${dotnet-sdk.unwrapped} -name libhostfxr${sharedLibrary}) $out/lib/mono/msbuild/Current/bin/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/ ln -s $(find ${dotnet-sdk.unwrapped}/share/dotnet -name libhostfxr${sharedLibrary}) $out/lib/mono/msbuild/Current/bin/SdkResolvers/Microsoft.DotNet.MSBuildSdkResolver/
''; '';
doInstallCheck = true; doInstallCheck = true;

View File

@ -36,7 +36,7 @@ let
cmakeFlags = [ cmakeFlags = [
"-DCORECLR_DIR=${coreclr-src}/src/coreclr" "-DCORECLR_DIR=${coreclr-src}/src/coreclr"
"-DDOTNET_DIR=${dotnet-sdk.unwrapped}" "-DDOTNET_DIR=${dotnet-sdk.unwrapped}/share/dotnet"
"-DBUILD_MANAGED=0" "-DBUILD_MANAGED=0"
]; ];
}; };

View File

@ -90,7 +90,7 @@ buildPythonApplication rec {
VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8 VIRTUALENV_NO_DOWNLOAD=1 PRE_COMMIT_NO_CONCURRENCY=1 LANG=en_US.UTF-8
# Resolve `.NET location: Not found` errors for dotnet tests # Resolve `.NET location: Not found` errors for dotnet tests
export DOTNET_ROOT="${dotnet-sdk.unwrapped}" export DOTNET_ROOT="${dotnet-sdk.unwrapped}/share/dotnet"
export HOME=$(mktemp -d) export HOME=$(mktemp -d)

View File

@ -143,14 +143,15 @@ mkWrapper type (stdenv.mkDerivation rec {
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p $out/bin
cp -r ./ $out
mkdir -p $out/share/doc/$pname/$version mkdir -p $out/share/doc/$pname/$version
mv $out/LICENSE.txt $out/share/doc/$pname/$version/ mv LICENSE.txt $out/share/doc/$pname/$version/
mv $out/ThirdPartyNotices.txt $out/share/doc/$pname/$version/ mv ThirdPartyNotices.txt $out/share/doc/$pname/$version/
ln -s $out/dotnet $out/bin/dotnet mkdir -p $out/share/dotnet
cp -r ./ $out/share/dotnet
mkdir -p $out/bin
ln -s $out/share/dotnet/dotnet $out/bin/dotnet
runHook postInstall runHook postInstall
''; '';
@ -161,17 +162,17 @@ mkWrapper type (stdenv.mkDerivation rec {
patchelf \ patchelf \
--add-needed libicui18n.so \ --add-needed libicui18n.so \
--add-needed libicuuc.so \ --add-needed libicuuc.so \
$out/shared/Microsoft.NETCore.App/*/libcoreclr.so \ $out/share/dotnet/shared/Microsoft.NETCore.App/*/libcoreclr.so \
$out/shared/Microsoft.NETCore.App/*/*System.Globalization.Native.so \ $out/share/dotnet/shared/Microsoft.NETCore.App/*/*System.Globalization.Native.so \
$out/packs/Microsoft.NETCore.App.Host.${hostRid}/*/runtimes/${hostRid}/native/*host $out/share/dotnet/packs/Microsoft.NETCore.App.Host.${hostRid}/*/runtimes/${hostRid}/native/*host
patchelf \ patchelf \
--add-needed libgssapi_krb5.so \ --add-needed libgssapi_krb5.so \
$out/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \ $out/share/dotnet/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \
$out/packs/Microsoft.NETCore.App.Host.${hostRid}/*/runtimes/${hostRid}/native/*host $out/share/dotnet/packs/Microsoft.NETCore.App.Host.${hostRid}/*/runtimes/${hostRid}/native/*host
patchelf \ patchelf \
--add-needed libssl.so \ --add-needed libssl.so \
$out/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \ $out/share/dotnet/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \
$out/packs/Microsoft.NETCore.App.Host.${hostRid}/*/runtimes/${hostRid}/native/*host $out/share/dotnet/packs/Microsoft.NETCore.App.Host.${hostRid}/*/runtimes/${hostRid}/native/*host
''; '';
# fixes: Could not load ICU data. UErrorCode: 2 # fixes: Could not load ICU data. UErrorCode: 2

View File

@ -21,20 +21,22 @@ assert lib.assertMsg ((builtins.length dotnetPackages) > 0) ''
buildEnv { buildEnv {
name = "dotnet-core-combined"; name = "dotnet-core-combined";
paths = map (x: x.unwrapped) dotnetPackages; paths = map (x: x.unwrapped) dotnetPackages;
pathsToLink = [ pathsToLink = map (x: "/share/dotnet/${x}") [
"/host" "host"
"/packs" "packs"
"/sdk" "sdk"
"/sdk-manifests" "sdk-manifests"
"/shared" "shared"
"/templates" "templates"
]; ];
ignoreCollisions = true; ignoreCollisions = true;
nativeBuildInputs = [ makeWrapper ];
postBuild = '' postBuild = ''
cp -R "${cli.unwrapped}"/dotnet $out/ mkdir -p "$out"/share/dotnet
cp "${cli.unwrapped}"/share/dotnet/dotnet $out/share/dotnet
cp -R "${cli}"/nix-support "$out"/ cp -R "${cli}"/nix-support "$out"/
mkdir "$out"/bin mkdir "$out"/bin
ln -s "$out"/dotnet "$out"/bin/dotnet ln -s "$out"/share/dotnet/dotnet "$out"/bin/dotnet
''; '';
passthru = { passthru = {
inherit (cli) icu; inherit (cli) icu;

View File

@ -115,10 +115,11 @@ let
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
cp -r "$src"/dotnet-sdk-${version}-${targetRid} "$out" mkdir -p "$out"/share
chmod +w "$out" cp -r "$src"/dotnet-sdk-${version}-${targetRid} "$out"/share/dotnet
chmod +w "$out"/share/dotnet
mkdir "$out"/bin mkdir "$out"/bin
ln -s "$out"/dotnet "$out"/bin/dotnet ln -s "$out"/share/dotnet/dotnet "$out"/bin/dotnet
mkdir -p "$artifacts" mkdir -p "$artifacts"
cp -r "$src"/Private.SourceBuilt.Artifacts.*.${targetRid}/* "$artifacts"/ cp -r "$src"/Private.SourceBuilt.Artifacts.*.${targetRid}/* "$artifacts"/
@ -160,10 +161,11 @@ let
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
cp -r "$src/dotnet-runtime-${version}-${targetRid}" "$out" mkdir -p "$out"/share
chmod +w "$out" cp -r "$src/dotnet-runtime-${version}-${targetRid}" "$out"/share/dotnet
chmod +w "$out"/share/dotnet
mkdir "$out"/bin mkdir "$out"/bin
ln -s "$out"/dotnet "$out"/bin/dotnet ln -s "$out"/share/dotnet/dotnet "$out"/bin/dotnet
runHook postInstall runHook postInstall
''; '';
@ -185,13 +187,14 @@ let
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
cp -r "$src/dotnet-runtime-${releaseManifest.runtimeVersion}-${targetRid}" "$out" mkdir -p "$out"/share
chmod +w "$out" cp -r "$src/dotnet-runtime-${runtime.version}-${targetRid}" "$out"/share/dotnet
chmod +w "$out"/share/dotnet/shared
mkdir "$out"/bin mkdir "$out"/bin
ln -s "$out"/dotnet "$out"/bin/dotnet ln -s "$out"/share/dotnet/dotnet "$out"/bin/dotnet
chmod +w "$out"/shared cp -Tr "$src/aspnetcore-runtime-${version}-${targetRid}" "$out"/share/dotnet
cp -Tr "$src/aspnetcore-runtime-${version}-${targetRid}" "$out" chmod +w "$out"/share/dotnet/shared
runHook postInstall runHook postInstall
''; '';

View File

@ -361,7 +361,7 @@ stdenv.mkDerivation rec {
# The build process tries to overwrite some things in the sdk (e.g. # The build process tries to overwrite some things in the sdk (e.g.
# SourceBuild.MSBuildSdkResolver.dll), so it needs to be mutable. # SourceBuild.MSBuildSdkResolver.dll), so it needs to be mutable.
cp -Tr ${bootstrapSdk} .dotnet cp -Tr ${bootstrapSdk}/share/dotnet .dotnet
chmod -R +w .dotnet chmod -R +w .dotnet
export HOME=$(mktemp -d) export HOME=$(mktemp -d)

View File

@ -31,7 +31,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
installPhase = '' installPhase = ''
runHook preInstall runHook preInstall
mkdir -p "$out"/bin mkdir -p "$out"/bin "$out"/share/dotnet
ln -s "$src"/bin/* "$out"/bin ln -s "$src"/bin/* "$out"/bin
runHook postInstall runHook postInstall
''; '';
@ -122,7 +122,7 @@ stdenvNoCC.mkDerivation (finalAttrs: {
( (
lib.optionalString (runtime != null) '' lib.optionalString (runtime != null) ''
# TODO: use runtime here # TODO: use runtime here
export DOTNET_ROOT=${runtime.unwrapped} export DOTNET_ROOT=${runtime.unwrapped}/share/dotnet
'' ''
+ run + run
); );

View File

@ -46,7 +46,7 @@ in
use-dotnet-root-env = testers.testEqualContents { use-dotnet-root-env = testers.testEqualContents {
assertion = "buildDotnetModule uses DOTNET_ROOT from environment in wrapper"; assertion = "buildDotnetModule uses DOTNET_ROOT from environment in wrapper";
expected = runtimeVersionFile; expected = runtimeVersionFile;
actual = runCommand "use-dotnet-from-env-root-test" { env.DOTNET_ROOT = dotnet-runtime.unwrapped; } '' actual = runCommand "use-dotnet-from-env-root-test" { env.DOTNET_ROOT = "${dotnet-runtime.unwrapped}/share/dotnet"; } ''
${appWithoutFallback}/bin/Application >"$out" ${appWithoutFallback}/bin/Application >"$out"
''; '';
}; };
@ -54,7 +54,7 @@ in
assertion = "buildDotnetModule uses DOTNET_ROOT from dotnet in PATH in wrapper"; assertion = "buildDotnetModule uses DOTNET_ROOT from dotnet in PATH in wrapper";
expected = runtimeVersionFile; expected = runtimeVersionFile;
actual = runCommand "use-dotnet-from-env-path-test" { dotnetRuntime = dotnet-runtime; } '' actual = runCommand "use-dotnet-from-env-path-test" { dotnetRuntime = dotnet-runtime; } ''
PATH=$dotnetRuntime''${PATH+:}$PATH ${appWithoutFallback}/bin/Application >"$out" PATH=$dotnetRuntime/bin''${PATH+:}$PATH ${appWithoutFallback}/bin/Application >"$out"
''; '';
}; };
} }