Fix useDotnetFromEnv's DOTNET_ROOT detection

This commit is contained in:
TomaSajt 2023-08-03 22:03:41 +02:00
parent 0271120180
commit ed60ed3562
No known key found for this signature in database
GPG Key ID: F011163C050122A1
3 changed files with 2 additions and 6 deletions

View File

@ -83,6 +83,7 @@ in
shell = stdenv.shell;
which = "${which}/bin/which";
dirname = "${coreutils}/bin/dirname";
realpath = "${coreutils}/bin/realpath";
};
} ./dotnet-fixup-hook.sh) { };
}

View File

@ -10,7 +10,7 @@ wrapDotnetProgram() {
if [ ! "${selfContainedBuild-}" ]; then
if [ "${useDotnetFromEnv-}" ]; then
# if dotnet CLI is available, set DOTNET_ROOT based on it. Otherwise set to default .NET runtime
dotnetRootFlags+=("--run" 'command -v dotnet &>/dev/null && export DOTNET_ROOT="$(@dirname@ "$(@dirname@ "$(@which@ dotnet)")")" || export DOTNET_ROOT="@dotnetRuntime@"')
dotnetRootFlags+=("--run" 'command -v dotnet &>/dev/null && export DOTNET_ROOT="$(@dirname@ "$(@realpath@ "$(@which@ dotnet)")")" || export DOTNET_ROOT="@dotnetRuntime@"')
dotnetRootFlags+=("--suffix" "PATH" ":" "@dotnetRuntime@/bin")
else
dotnetRootFlags+=("--set" "DOTNET_ROOT" "@dotnetRuntime@")

View File

@ -17,16 +17,11 @@ assert lib.assertMsg ((builtins.length dotnetPackages) > 0)
paths = dotnetPackages;
pathsToLink = [ "/host" "/packs" "/sdk" "/sdk-manifests" "/shared" "/templates" ];
ignoreCollisions = true;
nativeBuildInputs = [
makeWrapper
];
postBuild = ''
cp -R ${cli}/{dotnet,share,nix-support} $out/
mkdir $out/bin
ln -s $out/dotnet $out/bin/dotnet
wrapProgram $out/bin/dotnet \
--prefix LD_LIBRARY_PATH : ${cli.icu}/lib
'';
passthru = {
inherit (cli) icu;