0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-14 14:10:33 +03:00
nixpkgs/pkgs/development/compilers/dotnet/build-dotnet.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

121 lines
2.8 KiB
Nix
Raw Normal View History

{ type
, version
, srcs
, icu # passing icu as an argument, because dotnet 3.1 has troubles with icu71
, packages ? null
}:
2020-07-16 14:02:04 -07:00
2022-05-19 03:41:08 +02:00
assert builtins.elem type [ "aspnetcore" "runtime" "sdk" ];
assert if type == "sdk" then packages != null else true;
{ lib
, stdenv
, fetchurl
, writeText
2022-05-19 03:41:08 +02:00
, autoPatchelfHook
, makeWrapper
, libunwind
, openssl_1_1
, libuuid
, zlib
, curl
2021-04-05 16:01:43 +00:00
, lttng-ust_2_12
2020-07-16 14:02:04 -07:00
}:
let
2022-05-19 03:41:08 +02:00
pname =
if type == "aspnetcore" then
"aspnetcore-runtime"
else if type == "runtime" then
"dotnet-runtime"
else
"dotnet-sdk";
2020-07-16 14:02:04 -07:00
descriptions = {
aspnetcore = "ASP.NET Core Runtime ${version}";
runtime = ".NET Runtime ${version}";
2020-07-16 14:02:04 -07:00
sdk = ".NET SDK ${version}";
};
2022-05-19 03:41:08 +02:00
in
stdenv.mkDerivation rec {
2020-07-16 14:02:04 -07:00
inherit pname version;
2021-04-05 16:01:43 +00:00
# Some of these dependencies are `dlopen()`ed.
rpath = lib.makeLibraryPath ([
2021-04-05 16:01:43 +00:00
stdenv.cc.cc
zlib
2020-07-16 14:23:49 -07:00
curl
icu
libunwind
libuuid
openssl_1_1
2022-07-17 13:34:29 -07:00
] ++ lib.optional stdenv.isLinux lttng-ust_2_12);
2022-05-19 03:41:08 +02:00
nativeBuildInputs = [
makeWrapper
2022-07-17 13:34:29 -07:00
] ++ lib.optional stdenv.isLinux autoPatchelfHook;
2022-05-19 03:41:08 +02:00
buildInputs = [
stdenv.cc.cc
];
src = fetchurl (
srcs."${stdenv.hostPlatform.system}" or (throw
"Missing source (url and hash) for host system: ${stdenv.hostPlatform.system}")
);
2020-07-16 14:02:04 -07:00
sourceRoot = ".";
2020-07-16 14:02:04 -07:00
dontPatchELF = true;
noDumpEnvVars = true;
2020-07-16 14:02:04 -07:00
installPhase = ''
runHook preInstall
mkdir -p $out/bin
cp -r ./ $out
ln -s $out/dotnet $out/bin/dotnet
runHook postInstall
'';
postFixup = lib.optionalString stdenv.isLinux ''
2020-07-16 14:02:04 -07:00
patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" $out/dotnet
patchelf --set-rpath "${rpath}" $out/dotnet
find $out -type f -name "*.so" -exec patchelf --set-rpath '$ORIGIN:${rpath}' {} \;
2021-04-05 16:01:43 +00:00
find $out -type f \( -name "apphost" -or -name "createdump" \) -exec patchelf --set-interpreter "${stdenv.cc.bintools.dynamicLinker}" --set-rpath '$ORIGIN:${rpath}' {} \;
2022-05-19 03:41:08 +02:00
wrapProgram $out/bin/dotnet \
--prefix LD_LIBRARY_PATH : ${icu}/lib
2020-07-16 14:02:04 -07:00
'';
2020-07-16 14:02:04 -07:00
doInstallCheck = true;
installCheckPhase = ''
2022-05-19 03:41:08 +02:00
# Fixes cross
export DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=1
2020-07-16 14:02:04 -07:00
$out/bin/dotnet --info
'';
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-05-19 03:41:08 +02:00
passthru = {
inherit icu packages;
2022-05-19 03:41:08 +02:00
};
meta = with lib; {
2020-07-16 14:02:04 -07:00
description = builtins.getAttr type descriptions;
homepage = "https://dotnet.github.io/";
2020-07-16 14:02:04 -07:00
license = licenses.mit;
2022-05-15 10:54:10 +02:00
maintainers = with maintainers; [ kuznero mdarocha ];
mainProgram = "dotnet";
platforms = builtins.attrNames srcs;
2020-07-16 14:02:04 -07:00
};
}