From 824d40aa0400e547c07c054ed7eddcf42b68955e Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 26 Sep 2022 14:35:14 -0300 Subject: [PATCH] build-dotnet-module: restore for current runtime by default --- doc/languages-frameworks/dotnet.section.md | 1 - .../blockchains/wasabibackend/default.nix | 2 -- .../emulators/ryujinx/default.nix | 2 -- .../misc/ArchiSteamFarm/default.nix | 3 --- .../dotnet/build-dotnet-module/default.nix | 22 ++++++++++--------- .../build-dotnet-module/hooks/default.nix | 7 ++++-- .../hooks/dotnet-build-hook.sh | 2 +- .../hooks/dotnet-configure-hook.sh | 1 + .../hooks/dotnet-install-hook.sh | 3 +-- .../python-language-server/default.nix | 2 -- .../tools/omnisharp-roslyn/default.nix | 1 - pkgs/games/osu-lazer/default.nix | 4 ---- pkgs/games/xivlauncher/default.nix | 6 +---- pkgs/servers/jellyfin/default.nix | 16 -------------- pkgs/tools/games/ps3-disc-dumper/default.nix | 4 ---- 15 files changed, 21 insertions(+), 55 deletions(-) diff --git a/doc/languages-frameworks/dotnet.section.md b/doc/languages-frameworks/dotnet.section.md index 1baa135ae586..bfb193b1f021 100644 --- a/doc/languages-frameworks/dotnet.section.md +++ b/doc/languages-frameworks/dotnet.section.md @@ -121,7 +121,6 @@ in buildDotnetModule rec { dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-runtime = dotnetCorePackages.net_5_0; - dotnetFlags = [ "--runtime linux-x64" ]; executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`. executables = []; # Don't install any executables. diff --git a/pkgs/applications/blockchains/wasabibackend/default.nix b/pkgs/applications/blockchains/wasabibackend/default.nix index 4eca512bf48c..e4e97cae21a0 100644 --- a/pkgs/applications/blockchains/wasabibackend/default.nix +++ b/pkgs/applications/blockchains/wasabibackend/default.nix @@ -25,8 +25,6 @@ buildDotnetModule rec { dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-runtime = dotnetCorePackages.aspnetcore_3_1; - dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenv.targetPlatform.system}" ]; - nativeBuildInputs = [ autoPatchelfHook ]; buildInputs = [ stdenv.cc.cc.lib zlib ]; diff --git a/pkgs/applications/emulators/ryujinx/default.nix b/pkgs/applications/emulators/ryujinx/default.nix index e65dda41dc25..7f13892b936c 100644 --- a/pkgs/applications/emulators/ryujinx/default.nix +++ b/pkgs/applications/emulators/ryujinx/default.nix @@ -91,8 +91,6 @@ buildDotnetModule rec { "/p:ExtraDefineConstants=DISABLE_UPDATER" ]; - dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system}" ]; - executables = [ "Ryujinx.Headless.SDL2" "Ryujinx.Ava" diff --git a/pkgs/applications/misc/ArchiSteamFarm/default.nix b/pkgs/applications/misc/ArchiSteamFarm/default.nix index 6d735c26b425..7896604b0e9a 100644 --- a/pkgs/applications/misc/ArchiSteamFarm/default.nix +++ b/pkgs/applications/misc/ArchiSteamFarm/default.nix @@ -25,9 +25,6 @@ buildDotnetModule rec { nugetDeps = ./deps.nix; - # Without this dotnet attempts to restore for Windows targets, which it cannot find the dependencies for - dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system}" ]; - projectFile = "ArchiSteamFarm.sln"; executables = [ "ArchiSteamFarm" ]; diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index 17a82677c148..7f05a3a4eecc 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -59,6 +59,9 @@ # Libraries that need to be available at runtime should be passed through this. # These get wrapped into `LD_LIBRARY_PATH`. , runtimeDeps ? [ ] + # The dotnet runtime ID. If null, fetch-deps will gather dependencies for all + # platforms in meta.platforms which are supported by the sdk. +, runtimeId ? null # Tests to disable. This gets passed to `dotnet test --filter "FullyQualifiedName!={}"`, to ensure compatibility with all frameworks. # See https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-test#filter-option-details for more details. @@ -90,6 +93,10 @@ let inherit (callPackage ./hooks { inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType; + runtimeId = + if runtimeId != null + then runtimeId + else dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system; }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook; localDeps = @@ -156,16 +163,11 @@ stdenvNoCC.mkDerivation (args // { fetch-deps = let - # Derivations may set flags such as `--runtime ` based on the host platform to avoid restoring/building nuget dependencies they dont have or dont need. - # This introduces an issue; In this script we loop over all platforms from `meta` and add the RID flag for it, as to fetch all required dependencies. - # The script would inherit the RID flag from the derivation based on the platform building the script, and set the flag for any iteration we do over the RIDs. - # That causes conflicts. To circumvent it we remove all occurances of the flag. - flags = - let - isRuntime = flag: lib.hasPrefix "--runtime" flag; - in - builtins.filter (flag: !(isRuntime flag)) (dotnetFlags ++ dotnetRestoreFlags); - runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) platforms; + flags = dotnetFlags ++ dotnetRestoreFlags; + runtimeIds = + if runtimeId != null + then [ runtimeId ] + else map (system: dotnetCorePackages.systemToDotnetRid system) platforms; in writeShellScript "fetch-${pname}-deps" '' set -euo pipefail 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 1cc88602ff4c..2309ae6240d2 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix @@ -9,7 +9,9 @@ , dotnet-runtime , runtimeDeps , buildType +, runtimeId }: +assert (builtins.isString runtimeId); let libraryPath = lib.makeLibraryPath runtimeDeps; @@ -21,6 +23,7 @@ in deps = [ dotnet-sdk nuget-source ]; substitutions = { nugetSource = nuget-source; + inherit runtimeId; }; } ./dotnet-configure-hook.sh) { }; @@ -29,7 +32,7 @@ in name = "dotnet-build-hook"; deps = [ dotnet-sdk ]; substitutions = { - inherit buildType; + inherit buildType runtimeId; }; } ./dotnet-build-hook.sh) { }; @@ -49,7 +52,7 @@ in name = "dotnet-install-hook"; deps = [ dotnet-sdk ]; substitutions = { - inherit buildType; + inherit buildType runtimeId; }; } ./dotnet-install-hook.sh) { }; diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh index 782c170b0bb1..8f7f77339357 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-build-hook.sh @@ -15,7 +15,7 @@ dotnetBuildHook() { fi if [ "${selfContainedBuild-}" ]; then - dotnetBuildFlags+=("-p:SelfContained=true") + dotnetBuildFlags+=(--runtime "@runtimeId@" "-p:SelfContained=true") else dotnetBuildFlags+=("-p:SelfContained=false") fi diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh index 3479f58bb38c..1e33ebbaef71 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh @@ -18,6 +18,7 @@ dotnetConfigureHook() { env dotnet restore ${project-} \ -p:ContinuousIntegrationBuild=true \ -p:Deterministic=true \ + --runtime "@runtimeId@" \ --source "@nugetSource@/lib" \ ${parallelFlag-} \ ${dotnetRestoreFlags[@]} \ diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh index 196d2ca1af7a..831059f941ca 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-install-hook.sh @@ -7,7 +7,7 @@ dotnetInstallHook() { runHook preInstall if [ "${selfContainedBuild-}" ]; then - dotnetInstallFlags+=("--self-contained") + dotnetInstallFlags+=(--runtime "@runtimeId@" "--self-contained") else dotnetInstallFlags+=("--no-self-contained") fi @@ -21,7 +21,6 @@ dotnetInstallHook() { env dotnet publish ${project-} \ -p:ContinuousIntegrationBuild=true \ -p:Deterministic=true \ - -p:UseAppHost=true \ --output "$out/lib/${pname}" \ --configuration "@buildType@" \ --no-build \ diff --git a/pkgs/development/dotnet-modules/python-language-server/default.nix b/pkgs/development/dotnet-modules/python-language-server/default.nix index 4ef76c81ac9b..3044e884e3c6 100644 --- a/pkgs/development/dotnet-modules/python-language-server/default.nix +++ b/pkgs/development/dotnet-modules/python-language-server/default.nix @@ -26,8 +26,6 @@ buildDotnetModule rec { dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-runtime = dotnetCorePackages.runtime_3_1; - dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system}" ]; - nativeBuildInputs = [ autoPatchelfHook ]; buildInputs = [ stdenv.cc.cc.lib ]; runtimeDeps = [ openssl icu ]; diff --git a/pkgs/development/tools/omnisharp-roslyn/default.nix b/pkgs/development/tools/omnisharp-roslyn/default.nix index 0d42c494ce10..0fc9952b592c 100644 --- a/pkgs/development/tools/omnisharp-roslyn/default.nix +++ b/pkgs/development/tools/omnisharp-roslyn/default.nix @@ -29,7 +29,6 @@ let finalPackage = buildDotnetModule rec { patchelf ]; - dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenv.targetPlatform.system}" ]; dotnetInstallFlags = [ "--framework net6.0" ]; dotnetBuildFlags = [ "--framework net6.0" "--no-self-contained" ]; dotnetFlags = [ diff --git a/pkgs/games/osu-lazer/default.nix b/pkgs/games/osu-lazer/default.nix index cfcb69625d8b..f400c0e3e13e 100644 --- a/pkgs/games/osu-lazer/default.nix +++ b/pkgs/games/osu-lazer/default.nix @@ -28,10 +28,6 @@ buildDotnetModule rec { nativeBuildInputs = [ copyDesktopItems ]; - dotnetFlags = [ - "--runtime linux-x64" - ]; - runtimeDeps = [ ffmpeg alsa-lib diff --git a/pkgs/games/xivlauncher/default.nix b/pkgs/games/xivlauncher/default.nix index 0bd586d458c2..b8560f2b4134 100644 --- a/pkgs/games/xivlauncher/default.nix +++ b/pkgs/games/xivlauncher/default.nix @@ -23,12 +23,8 @@ in nugetDeps = ./deps.nix; # File generated with `nix-build -A xivlauncher.passthru.fetch-deps` dotnetFlags = [ - "--runtime linux-x64" "-p:BuildHash=${rev}" - ]; - - dotnetBuildFlags = [ - "--no-self-contained" + "-p:PublishSingleFile=false" ]; postPatch = '' diff --git a/pkgs/servers/jellyfin/default.nix b/pkgs/servers/jellyfin/default.nix index 4848dcba9f06..1943d107ad0f 100644 --- a/pkgs/servers/jellyfin/default.nix +++ b/pkgs/servers/jellyfin/default.nix @@ -12,21 +12,6 @@ , sqlite }: -let - os = if stdenv.isDarwin then "osx" else "linux"; - arch = - with stdenv.hostPlatform; - if isx86_32 then "x86" - else if isx86_64 then "x64" - else if isAarch32 then "arm" - else if isAarch64 then "arm64" - else lib.warn "Unsupported architecture, some image processing features might be unavailable" "unknown"; - musl = lib.optionalString stdenv.hostPlatform.isMusl - (lib.warnIf (arch != "x64") "Some image processing features might be unavailable for non x86-64 with Musl" - "musl-"); - # https://docs.microsoft.com/en-us/dotnet/core/rid-catalog#using-rids - runtimeId = "${os}-${musl}${arch}"; -in buildDotnetModule rec { pname = "jellyfin"; version = "10.8.8"; # ensure that jellyfin-web has matching version @@ -57,7 +42,6 @@ buildDotnetModule rec { ]; dotnet-sdk = dotnetCorePackages.sdk_6_0; dotnet-runtime = dotnetCorePackages.aspnetcore_6_0; - dotnetFlags = [ "--runtime=${runtimeId}" ]; dotnetBuildFlags = [ "--no-self-contained" ]; preInstall = '' diff --git a/pkgs/tools/games/ps3-disc-dumper/default.nix b/pkgs/tools/games/ps3-disc-dumper/default.nix index 523ae25a9499..577be9738486 100644 --- a/pkgs/tools/games/ps3-disc-dumper/default.nix +++ b/pkgs/tools/games/ps3-disc-dumper/default.nix @@ -27,10 +27,6 @@ buildDotnetModule rec { openssl ]; - dotnetFlags = [ - "--runtime linux-x64" - ]; - meta = with lib; { homepage = "https://github.com/13xforever/ps3-disc-dumper"; description = "A handy utility to make decrypted PS3 disc dumps";