7 assert builtins.elem type [ "aspnetcore" "runtime" "sdk" ];
8 assert if type == "sdk" then packages != null else true;
31 if type == "aspnetcore" then
33 else if type == "runtime" then
39 aspnetcore = "ASP.NET Core Runtime ${version}";
40 runtime = ".NET Runtime ${version}";
41 sdk = ".NET SDK ${version}";
44 packageDeps = if type == "sdk" then mkNugetDeps {
45 name = "${pname}-${version}-deps";
50 stdenv.mkDerivation (finalAttrs: rec {
51 inherit pname version;
53 # Some of these dependencies are `dlopen()`ed.
56 ] ++ lib.optional stdenv.isLinux autoPatchelfHook;
64 ] ++ lib.optional stdenv.isLinux lttng-ust_2_12;
67 srcs."${stdenv.hostPlatform.system}" or (throw
68 "Missing source (url and hash) for host system: ${stdenv.hostPlatform.system}")
82 mkdir -p $out/share/doc/$pname/$version
83 mv $out/LICENSE.txt $out/share/doc/$pname/$version/
84 mv $out/ThirdPartyNotices.txt $out/share/doc/$pname/$version/
86 ln -s $out/dotnet $out/bin/dotnet
91 doInstallCheck = true;
92 installCheckPhase = ''
93 $out/bin/dotnet --info
96 # Tell autoPatchelf about runtime dependencies.
97 # (postFixup phase is run before autoPatchelfHook.)
98 postFixup = lib.optionalString stdenv.isLinux ''
100 --add-needed libicui18n.so \
101 --add-needed libicuuc.so \
102 $out/shared/Microsoft.NETCore.App/*/libcoreclr.so \
103 $out/shared/Microsoft.NETCore.App/*/*System.Globalization.Native.so \
104 $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
106 --add-needed libgssapi_krb5.so \
107 $out/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \
108 $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
110 --add-needed libssl.so \
111 $out/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \
112 $out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
115 setupHook = writeText "dotnet-setup-hook" ''
116 if [ ! -w "$HOME" ]; then
117 export HOME=$(mktemp -d) # Dotnet expects a writable home directory for its configuration files
120 export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 # Dont try to expand NuGetFallbackFolder to disk
121 export DOTNET_NOLOGO=1 # Disables the welcome message
122 export DOTNET_CLI_TELEMETRY_OPTOUT=1
127 packages = packageDeps;
130 if type == "sdk" then
134 concatStringsSep "." (take 2 (splitVersion version));
136 writeShellScript "update-dotnet-${majorVersion}" ''
137 pushd pkgs/development/compilers/dotnet
138 exec ${./update.sh} "${majorVersion}"
142 version = testers.testVersion {
143 package = finalAttrs.finalPackage;
146 smoke-test = runCommand "dotnet-sdk-smoke-test" {
147 nativeBuildInputs = [ finalAttrs.finalPackage ];
149 HOME=$(pwd)/fake-home
152 output="$(dotnet run)"
153 # yes, older SDKs omit the comma
154 [[ "$output" =~ Hello,?\ World! ]] && touch "$out"
160 description = builtins.getAttr type descriptions;
161 homepage = "https://dotnet.github.io/";
162 license = licenses.mit;
163 maintainers = with maintainers; [ kuznero mdarocha ];
164 mainProgram = "dotnet";
165 platforms = attrNames srcs;