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.
`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}
<!-- 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
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$wrapperPath")
dotnetRootFlagsArray+=("--run" "$dotnetFromEnvScript")
dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime")
dotnetRootFlagsArray+=("--set-default" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
dotnetRootFlagsArray+=("--suffix" "PATH" ":" "$dotnetRuntime/bin")
else
dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime")
dotnetRootFlagsArray+=("--set" "DOTNET_ROOT" "$dotnetRuntime/share/dotnet")
dotnetRootFlagsArray+=("--prefix" "PATH" ":" "$dotnetRuntime/bin")
fi
fi

View File

@ -32,7 +32,7 @@
let
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";

View File

@ -72,7 +72,7 @@ mkPackage rec {
# The provided libhostfxr.dylib is for x86_64-darwin, so we remove it
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
echo "#!${stdenv.shell}" > eng/common/dotnet-install.sh
@ -82,7 +82,7 @@ mkPackage rec {
echo "#!${stdenv.shell}" > mono/build/extract_and_copy_hostfxr.sh
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
# TODO there are some (many?) failing tests
@ -99,7 +99,7 @@ mkPackage rec {
--set-default MONO_GC_PARAMS "nursery-size=64m" \
--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;

View File

@ -36,7 +36,7 @@ let
cmakeFlags = [
"-DCORECLR_DIR=${coreclr-src}/src/coreclr"
"-DDOTNET_DIR=${dotnet-sdk.unwrapped}"
"-DDOTNET_DIR=${dotnet-sdk.unwrapped}/share/dotnet"
"-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
# 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)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ in
use-dotnet-root-env = testers.testEqualContents {
assertion = "buildDotnetModule uses DOTNET_ROOT from environment in wrapper";
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"
'';
};
@ -54,7 +54,7 @@ in
assertion = "buildDotnetModule uses DOTNET_ROOT from dotnet in PATH in wrapper";
expected = runtimeVersionFile;
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"
'';
};
}