2020-08-20 17:08:02 +00:00
|
|
|
{ type
|
|
|
|
, version
|
2022-03-30 09:31:56 +00:00
|
|
|
, srcs
|
2022-08-21 13:32:41 +00:00
|
|
|
, icu # passing icu as an argument, because dotnet 3.1 has troubles with icu71
|
|
|
|
, packages ? null
|
2020-08-20 17:08:02 +00:00
|
|
|
}:
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
assert builtins.elem type [ "aspnetcore" "runtime" "sdk" ];
|
2022-08-21 13:32:41 +00:00
|
|
|
assert if type == "sdk" then packages != null else true;
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-08-20 17:08:02 +00:00
|
|
|
, fetchurl
|
2022-03-30 09:31:56 +00:00
|
|
|
, writeText
|
2022-07-18 16:21:45 +00:00
|
|
|
, autoPatchelfHook
|
|
|
|
, makeWrapper
|
2020-08-20 17:08:02 +00:00
|
|
|
, libunwind
|
2022-09-14 18:05:37 +00:00
|
|
|
, openssl_1_1
|
2020-08-20 17:08:02 +00:00
|
|
|
, libuuid
|
|
|
|
, zlib
|
2022-09-22 12:36:57 +00:00
|
|
|
, libkrb5
|
2020-08-20 17:08:02 +00:00
|
|
|
, curl
|
2021-12-19 01:06:50 +00:00
|
|
|
, lttng-ust_2_12
|
2022-09-22 12:36:57 +00:00
|
|
|
, testers
|
|
|
|
, runCommand
|
2022-09-30 11:47:45 +00:00
|
|
|
, writeShellScript
|
2022-12-28 21:21:41 +00:00
|
|
|
, mkNugetDeps
|
2020-08-20 17:08:02 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2022-07-18 16:21:45 +00:00
|
|
|
pname =
|
|
|
|
if type == "aspnetcore" then
|
|
|
|
"aspnetcore-runtime"
|
|
|
|
else if type == "runtime" then
|
|
|
|
"dotnet-runtime"
|
|
|
|
else
|
|
|
|
"dotnet-sdk";
|
2022-03-30 09:31:56 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
descriptions = {
|
2021-10-17 09:34:42 +00:00
|
|
|
aspnetcore = "ASP.NET Core Runtime ${version}";
|
|
|
|
runtime = ".NET Runtime ${version}";
|
2020-08-20 17:08:02 +00:00
|
|
|
sdk = ".NET SDK ${version}";
|
|
|
|
};
|
2022-12-28 21:21:41 +00:00
|
|
|
|
|
|
|
packageDeps = mkNugetDeps {
|
|
|
|
name = "${pname}-${version}-deps";
|
|
|
|
nugetDeps = packages;
|
|
|
|
};
|
|
|
|
|
2022-07-18 16:21:45 +00:00
|
|
|
in
|
2022-09-22 12:36:57 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: rec {
|
2020-08-20 17:08:02 +00:00
|
|
|
inherit pname version;
|
|
|
|
|
2021-12-19 01:06:50 +00:00
|
|
|
# Some of these dependencies are `dlopen()`ed.
|
2022-07-18 16:21:45 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
makeWrapper
|
|
|
|
] ++ lib.optional stdenv.isLinux autoPatchelfHook;
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
stdenv.cc.cc
|
2022-09-22 12:36:57 +00:00
|
|
|
zlib
|
|
|
|
icu
|
|
|
|
libkrb5
|
|
|
|
# this must be before curl for autoPatchElf to find it
|
|
|
|
# curl brings in its own openssl
|
|
|
|
openssl_1_1
|
|
|
|
curl
|
|
|
|
] ++ lib.optional stdenv.isLinux lttng-ust_2_12;
|
2022-07-18 16:21:45 +00:00
|
|
|
|
|
|
|
src = fetchurl (
|
|
|
|
srcs."${stdenv.hostPlatform.system}" or (throw
|
|
|
|
"Missing source (url and hash) for host system: ${stdenv.hostPlatform.system}")
|
|
|
|
);
|
2020-08-20 17:08:02 +00:00
|
|
|
|
|
|
|
sourceRoot = ".";
|
|
|
|
|
|
|
|
dontPatchELF = true;
|
|
|
|
noDumpEnvVars = true;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2022-10-06 18:32:54 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
mkdir -p $out/bin
|
|
|
|
cp -r ./ $out
|
2022-10-06 18:32:54 +00:00
|
|
|
|
|
|
|
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/
|
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
ln -s $out/dotnet $out/bin/dotnet
|
2022-10-06 18:32:54 +00:00
|
|
|
|
2020-08-20 17:08:02 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
doInstallCheck = true;
|
|
|
|
installCheckPhase = ''
|
|
|
|
$out/bin/dotnet --info
|
|
|
|
'';
|
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
# Tell autoPatchelf about runtime dependencies.
|
|
|
|
# (postFixup phase is run before autoPatchelfHook.)
|
|
|
|
postFixup = lib.optionalString stdenv.isLinux ''
|
|
|
|
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.linux-x64/*/runtimes/linux-x64/native/singlefilehost
|
|
|
|
patchelf \
|
|
|
|
--add-needed libgssapi_krb5.so \
|
|
|
|
$out/shared/Microsoft.NETCore.App/*/*System.Net.Security.Native.so \
|
|
|
|
$out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
|
|
|
|
patchelf \
|
|
|
|
--add-needed libssl.so \
|
|
|
|
$out/shared/Microsoft.NETCore.App/*/*System.Security.Cryptography.Native.OpenSsl.so \
|
|
|
|
$out/packs/Microsoft.NETCore.App.Host.linux-x64/*/runtimes/linux-x64/native/singlefilehost
|
|
|
|
'';
|
|
|
|
|
2022-03-30 09:31:56 +00:00
|
|
|
setupHook = writeText "dotnet-setup-hook" ''
|
|
|
|
if [ ! -w "$HOME" ]; then
|
|
|
|
export HOME=$(mktemp -d) # Dotnet expects a writable home directory for its configuration files
|
|
|
|
fi
|
|
|
|
|
|
|
|
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 # Dont try to expand NuGetFallbackFolder to disk
|
|
|
|
export DOTNET_NOLOGO=1 # Disables the welcome message
|
|
|
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
|
|
|
'';
|
|
|
|
|
2022-09-14 18:05:37 +00:00
|
|
|
passthru = rec {
|
2022-12-28 21:21:41 +00:00
|
|
|
inherit icu;
|
|
|
|
packages = packageDeps;
|
2022-09-14 18:05:37 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
updateScript =
|
2022-10-21 18:38:19 +00:00
|
|
|
if type == "sdk" then
|
2022-09-30 11:47:45 +00:00
|
|
|
let
|
|
|
|
majorVersion =
|
|
|
|
with lib;
|
|
|
|
concatStringsSep "." (take 2 (splitVersion version));
|
|
|
|
in
|
|
|
|
writeShellScript "update-dotnet-${majorVersion}" ''
|
|
|
|
pushd pkgs/development/compilers/dotnet
|
|
|
|
exec ${./update.sh} "${majorVersion}"
|
2022-10-21 18:38:19 +00:00
|
|
|
'' else null;
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2022-09-22 12:36:57 +00:00
|
|
|
tests = {
|
|
|
|
version = testers.testVersion {
|
|
|
|
package = finalAttrs.finalPackage;
|
|
|
|
};
|
|
|
|
|
|
|
|
smoke-test = runCommand "dotnet-sdk-smoke-test" {
|
|
|
|
nativeBuildInputs = [ finalAttrs.finalPackage ];
|
|
|
|
} ''
|
|
|
|
HOME=$(pwd)/fake-home
|
|
|
|
dotnet new console
|
|
|
|
dotnet build
|
|
|
|
output="$(dotnet run)"
|
|
|
|
# yes, older SDKs omit the comma
|
|
|
|
[[ "$output" =~ Hello,?\ World! ]] && touch "$out"
|
|
|
|
'';
|
|
|
|
};
|
2022-07-18 16:21:45 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-08-20 17:08:02 +00:00
|
|
|
description = builtins.getAttr type descriptions;
|
2022-05-18 14:49:53 +00:00
|
|
|
homepage = "https://dotnet.github.io/";
|
2020-08-20 17:08:02 +00:00
|
|
|
license = licenses.mit;
|
2022-06-16 17:23:12 +00:00
|
|
|
maintainers = with maintainers; [ kuznero mdarocha ];
|
2022-05-18 14:49:53 +00:00
|
|
|
mainProgram = "dotnet";
|
2022-09-22 12:36:57 +00:00
|
|
|
platforms = attrNames srcs;
|
2020-08-20 17:08:02 +00:00
|
|
|
};
|
2022-09-22 12:36:57 +00:00
|
|
|
})
|