From 895b69405c103f218ca5bed47efbb0ef71bb577f Mon Sep 17 00:00:00 2001 From: js6pak Date: Sun, 24 Nov 2024 22:40:41 +0100 Subject: [PATCH] dotnet: make wrappers usable as DOTNET_ROOT This simplifies the code a bit and makes it possible to use dotnetCorePackages.combinePackages as dotnet-runtime again. Partial revert of ddd08e404f21d39ae6592ae359f416e7b0fd8462. --- .../dotnet/build-dotnet-module/hooks/default.nix | 3 +-- pkgs/by-name/dy/dyalog/package.nix | 2 +- pkgs/by-name/ne/netcoredbg/package.nix | 2 +- pkgs/by-name/pr/pre-commit/package.nix | 2 +- pkgs/development/compilers/dotnet/combine-packages.nix | 4 ++-- pkgs/development/compilers/dotnet/wrapper.nix | 6 +++--- pkgs/test/dotnet/use-dotnet-from-env/default.nix | 4 ++-- 7 files changed, 11 insertions(+), 12 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix index e589804fbe32..1110e01f7dd9 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix @@ -52,8 +52,7 @@ { name = "dotnet-fixup-hook"; substitutions = { - # this is used for DOTNET_ROOT, so we need unwrapped - dotnetRuntime = if (dotnet-runtime != null) then dotnet-runtime.unwrapped else null; + dotnetRuntime = if (dotnet-runtime != null) then dotnet-runtime else null; wrapperPath = lib.makeBinPath [ which coreutils ]; }; } diff --git a/pkgs/by-name/dy/dyalog/package.nix b/pkgs/by-name/dy/dyalog/package.nix index 310ec6a8bc34..a0c7be275547 100644 --- a/pkgs/by-name/dy/dyalog/package.nix +++ b/pkgs/by-name/dy/dyalog/package.nix @@ -32,7 +32,7 @@ let dyalogHome = "$out/lib/dyalog"; - makeWrapperArgs = lib.optional dotnetSupport "--set DOTNET_ROOT ${dotnet-sdk_8.unwrapped}/share/dotnet"; + makeWrapperArgs = lib.optional dotnetSupport "--set DOTNET_ROOT ${dotnet-sdk_8}/share/dotnet"; licenseUrl = "https://www.dyalog.com/uploads/documents/Developer_Software_Licence.pdf"; diff --git a/pkgs/by-name/ne/netcoredbg/package.nix b/pkgs/by-name/ne/netcoredbg/package.nix index 48d62500e116..6b9773cb60db 100644 --- a/pkgs/by-name/ne/netcoredbg/package.nix +++ b/pkgs/by-name/ne/netcoredbg/package.nix @@ -36,7 +36,7 @@ let cmakeFlags = [ "-DCORECLR_DIR=${coreclr-src}/src/coreclr" - "-DDOTNET_DIR=${dotnet-sdk.unwrapped}/share/dotnet" + "-DDOTNET_DIR=${dotnet-sdk}/share/dotnet" "-DBUILD_MANAGED=0" ]; }; diff --git a/pkgs/by-name/pr/pre-commit/package.nix b/pkgs/by-name/pr/pre-commit/package.nix index c5c62a54499f..a35ffa3072dd 100644 --- a/pkgs/by-name/pr/pre-commit/package.nix +++ b/pkgs/by-name/pr/pre-commit/package.nix @@ -93,7 +93,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}/share/dotnet" + export DOTNET_ROOT="${dotnet-sdk}/share/dotnet" export HOME=$(mktemp -d) diff --git a/pkgs/development/compilers/dotnet/combine-packages.nix b/pkgs/development/compilers/dotnet/combine-packages.nix index 2b5554b2eb94..aefc77906974 100644 --- a/pkgs/development/compilers/dotnet/combine-packages.nix +++ b/pkgs/development/compilers/dotnet/combine-packages.nix @@ -20,7 +20,7 @@ assert lib.assertMsg ((builtins.length dotnetPackages) > 0) '' ];`''; (buildEnv { name = "dotnet-core-combined"; - paths = map (x: x.unwrapped) dotnetPackages; + paths = dotnetPackages; pathsToLink = map (x: "/share/dotnet/${x}") [ "host" "packs" @@ -34,7 +34,7 @@ assert lib.assertMsg ((builtins.length dotnetPackages) > 0) '' postBuild = '' mkdir -p "$out"/share/dotnet - cp "${cli.unwrapped}"/share/dotnet/dotnet $out/share/dotnet + cp "${cli}"/share/dotnet/dotnet $out/share/dotnet cp -R "${cli}"/nix-support "$out"/ mkdir "$out"/bin ln -s "$out"/share/dotnet/dotnet "$out"/bin/dotnet diff --git a/pkgs/development/compilers/dotnet/wrapper.nix b/pkgs/development/compilers/dotnet/wrapper.nix index 3e492491afd7..fe09151fb8fe 100644 --- a/pkgs/development/compilers/dotnet/wrapper.nix +++ b/pkgs/development/compilers/dotnet/wrapper.nix @@ -46,8 +46,9 @@ stdenvNoCC.mkDerivation (finalAttrs: { installPhase = '' runHook preInstall - mkdir -p "$out"/bin "$out"/share/dotnet + mkdir -p "$out"/bin "$out"/share ln -s "$src"/bin/* "$out"/bin + ln -s "$src"/share/dotnet "$out"/share runHook postInstall ''; @@ -125,8 +126,7 @@ stdenvNoCC.mkDerivation (finalAttrs: { ) ( lib.optionalString (runtime != null) '' - # TODO: use runtime here - export DOTNET_ROOT=${runtime.unwrapped}/share/dotnet + export DOTNET_ROOT=${runtime}/share/dotnet '' + run ); diff --git a/pkgs/test/dotnet/use-dotnet-from-env/default.nix b/pkgs/test/dotnet/use-dotnet-from-env/default.nix index 2fedc633b176..6aa3d3bab590 100644 --- a/pkgs/test/dotnet/use-dotnet-from-env/default.nix +++ b/pkgs/test/dotnet/use-dotnet-from-env/default.nix @@ -21,7 +21,7 @@ let removeReferencesTo ]; postFixup = (oldAttrs.postFixup or "") + '' - remove-references-to -t ${dotnet-runtime.unwrapped} "$out/bin/Application" + remove-references-to -t ${dotnet-runtime} "$out/bin/Application" ''; }); @@ -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}/share/dotnet"; } '' + actual = runCommand "use-dotnet-from-env-root-test" { env.DOTNET_ROOT = "${dotnet-runtime}/share/dotnet"; } '' ${appWithoutFallback}/bin/Application >"$out" ''; };