build-dotnet-module: restore for current runtime by default

This commit is contained in:
David McFarland 2022-09-26 14:35:14 -03:00
parent 13861970f4
commit 824d40aa04
15 changed files with 21 additions and 55 deletions

View File

@ -121,7 +121,6 @@ in buildDotnetModule rec {
dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-sdk = dotnetCorePackages.sdk_3_1;
dotnet-runtime = dotnetCorePackages.net_5_0; dotnet-runtime = dotnetCorePackages.net_5_0;
dotnetFlags = [ "--runtime linux-x64" ];
executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`. executables = [ "foo" ]; # This wraps "$out/lib/$pname/foo" to `$out/bin/foo`.
executables = []; # Don't install any executables. executables = []; # Don't install any executables.

View File

@ -25,8 +25,6 @@ buildDotnetModule rec {
dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-sdk = dotnetCorePackages.sdk_3_1;
dotnet-runtime = dotnetCorePackages.aspnetcore_3_1; dotnet-runtime = dotnetCorePackages.aspnetcore_3_1;
dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenv.targetPlatform.system}" ];
nativeBuildInputs = [ autoPatchelfHook ]; nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [ stdenv.cc.cc.lib zlib ]; buildInputs = [ stdenv.cc.cc.lib zlib ];

View File

@ -91,8 +91,6 @@ buildDotnetModule rec {
"/p:ExtraDefineConstants=DISABLE_UPDATER" "/p:ExtraDefineConstants=DISABLE_UPDATER"
]; ];
dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system}" ];
executables = [ executables = [
"Ryujinx.Headless.SDL2" "Ryujinx.Headless.SDL2"
"Ryujinx.Ava" "Ryujinx.Ava"

View File

@ -25,9 +25,6 @@ buildDotnetModule rec {
nugetDeps = ./deps.nix; 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"; projectFile = "ArchiSteamFarm.sln";
executables = [ "ArchiSteamFarm" ]; executables = [ "ArchiSteamFarm" ];

View File

@ -59,6 +59,9 @@
# Libraries that need to be available at runtime should be passed through this. # Libraries that need to be available at runtime should be passed through this.
# These get wrapped into `LD_LIBRARY_PATH`. # These get wrapped into `LD_LIBRARY_PATH`.
, runtimeDeps ? [ ] , 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. # 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. # 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 (callPackage ./hooks {
inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType; 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; }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
localDeps = localDeps =
@ -156,16 +163,11 @@ stdenvNoCC.mkDerivation (args // {
fetch-deps = fetch-deps =
let let
# Derivations may set flags such as `--runtime <rid>` based on the host platform to avoid restoring/building nuget dependencies they dont have or dont need. flags = dotnetFlags ++ dotnetRestoreFlags;
# 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. runtimeIds =
# 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. if runtimeId != null
# That causes conflicts. To circumvent it we remove all occurances of the flag. then [ runtimeId ]
flags = else map (system: dotnetCorePackages.systemToDotnetRid system) platforms;
let
isRuntime = flag: lib.hasPrefix "--runtime" flag;
in
builtins.filter (flag: !(isRuntime flag)) (dotnetFlags ++ dotnetRestoreFlags);
runtimeIds = map (system: dotnetCorePackages.systemToDotnetRid system) platforms;
in in
writeShellScript "fetch-${pname}-deps" '' writeShellScript "fetch-${pname}-deps" ''
set -euo pipefail set -euo pipefail

View File

@ -9,7 +9,9 @@
, dotnet-runtime , dotnet-runtime
, runtimeDeps , runtimeDeps
, buildType , buildType
, runtimeId
}: }:
assert (builtins.isString runtimeId);
let let
libraryPath = lib.makeLibraryPath runtimeDeps; libraryPath = lib.makeLibraryPath runtimeDeps;
@ -21,6 +23,7 @@ in
deps = [ dotnet-sdk nuget-source ]; deps = [ dotnet-sdk nuget-source ];
substitutions = { substitutions = {
nugetSource = nuget-source; nugetSource = nuget-source;
inherit runtimeId;
}; };
} ./dotnet-configure-hook.sh) { }; } ./dotnet-configure-hook.sh) { };
@ -29,7 +32,7 @@ in
name = "dotnet-build-hook"; name = "dotnet-build-hook";
deps = [ dotnet-sdk ]; deps = [ dotnet-sdk ];
substitutions = { substitutions = {
inherit buildType; inherit buildType runtimeId;
}; };
} ./dotnet-build-hook.sh) { }; } ./dotnet-build-hook.sh) { };
@ -49,7 +52,7 @@ in
name = "dotnet-install-hook"; name = "dotnet-install-hook";
deps = [ dotnet-sdk ]; deps = [ dotnet-sdk ];
substitutions = { substitutions = {
inherit buildType; inherit buildType runtimeId;
}; };
} ./dotnet-install-hook.sh) { }; } ./dotnet-install-hook.sh) { };

View File

@ -15,7 +15,7 @@ dotnetBuildHook() {
fi fi
if [ "${selfContainedBuild-}" ]; then if [ "${selfContainedBuild-}" ]; then
dotnetBuildFlags+=("-p:SelfContained=true") dotnetBuildFlags+=(--runtime "@runtimeId@" "-p:SelfContained=true")
else else
dotnetBuildFlags+=("-p:SelfContained=false") dotnetBuildFlags+=("-p:SelfContained=false")
fi fi

View File

@ -18,6 +18,7 @@ dotnetConfigureHook() {
env dotnet restore ${project-} \ env dotnet restore ${project-} \
-p:ContinuousIntegrationBuild=true \ -p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \ -p:Deterministic=true \
--runtime "@runtimeId@" \
--source "@nugetSource@/lib" \ --source "@nugetSource@/lib" \
${parallelFlag-} \ ${parallelFlag-} \
${dotnetRestoreFlags[@]} \ ${dotnetRestoreFlags[@]} \

View File

@ -7,7 +7,7 @@ dotnetInstallHook() {
runHook preInstall runHook preInstall
if [ "${selfContainedBuild-}" ]; then if [ "${selfContainedBuild-}" ]; then
dotnetInstallFlags+=("--self-contained") dotnetInstallFlags+=(--runtime "@runtimeId@" "--self-contained")
else else
dotnetInstallFlags+=("--no-self-contained") dotnetInstallFlags+=("--no-self-contained")
fi fi
@ -21,7 +21,6 @@ dotnetInstallHook() {
env dotnet publish ${project-} \ env dotnet publish ${project-} \
-p:ContinuousIntegrationBuild=true \ -p:ContinuousIntegrationBuild=true \
-p:Deterministic=true \ -p:Deterministic=true \
-p:UseAppHost=true \
--output "$out/lib/${pname}" \ --output "$out/lib/${pname}" \
--configuration "@buildType@" \ --configuration "@buildType@" \
--no-build \ --no-build \

View File

@ -26,8 +26,6 @@ buildDotnetModule rec {
dotnet-sdk = dotnetCorePackages.sdk_3_1; dotnet-sdk = dotnetCorePackages.sdk_3_1;
dotnet-runtime = dotnetCorePackages.runtime_3_1; dotnet-runtime = dotnetCorePackages.runtime_3_1;
dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenvNoCC.targetPlatform.system}" ];
nativeBuildInputs = [ autoPatchelfHook ]; nativeBuildInputs = [ autoPatchelfHook ];
buildInputs = [ stdenv.cc.cc.lib ]; buildInputs = [ stdenv.cc.cc.lib ];
runtimeDeps = [ openssl icu ]; runtimeDeps = [ openssl icu ];

View File

@ -29,7 +29,6 @@ let finalPackage = buildDotnetModule rec {
patchelf patchelf
]; ];
dotnetRestoreFlags = [ "--runtime ${dotnetCorePackages.systemToDotnetRid stdenv.targetPlatform.system}" ];
dotnetInstallFlags = [ "--framework net6.0" ]; dotnetInstallFlags = [ "--framework net6.0" ];
dotnetBuildFlags = [ "--framework net6.0" "--no-self-contained" ]; dotnetBuildFlags = [ "--framework net6.0" "--no-self-contained" ];
dotnetFlags = [ dotnetFlags = [

View File

@ -28,10 +28,6 @@ buildDotnetModule rec {
nativeBuildInputs = [ copyDesktopItems ]; nativeBuildInputs = [ copyDesktopItems ];
dotnetFlags = [
"--runtime linux-x64"
];
runtimeDeps = [ runtimeDeps = [
ffmpeg ffmpeg
alsa-lib alsa-lib

View File

@ -23,12 +23,8 @@ in
nugetDeps = ./deps.nix; # File generated with `nix-build -A xivlauncher.passthru.fetch-deps` nugetDeps = ./deps.nix; # File generated with `nix-build -A xivlauncher.passthru.fetch-deps`
dotnetFlags = [ dotnetFlags = [
"--runtime linux-x64"
"-p:BuildHash=${rev}" "-p:BuildHash=${rev}"
]; "-p:PublishSingleFile=false"
dotnetBuildFlags = [
"--no-self-contained"
]; ];
postPatch = '' postPatch = ''

View File

@ -12,21 +12,6 @@
, sqlite , 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 { buildDotnetModule rec {
pname = "jellyfin"; pname = "jellyfin";
version = "10.8.8"; # ensure that jellyfin-web has matching version version = "10.8.8"; # ensure that jellyfin-web has matching version
@ -57,7 +42,6 @@ buildDotnetModule rec {
]; ];
dotnet-sdk = dotnetCorePackages.sdk_6_0; dotnet-sdk = dotnetCorePackages.sdk_6_0;
dotnet-runtime = dotnetCorePackages.aspnetcore_6_0; dotnet-runtime = dotnetCorePackages.aspnetcore_6_0;
dotnetFlags = [ "--runtime=${runtimeId}" ];
dotnetBuildFlags = [ "--no-self-contained" ]; dotnetBuildFlags = [ "--no-self-contained" ];
preInstall = '' preInstall = ''

View File

@ -27,10 +27,6 @@ buildDotnetModule rec {
openssl openssl
]; ];
dotnetFlags = [
"--runtime linux-x64"
];
meta = with lib; { meta = with lib; {
homepage = "https://github.com/13xforever/ps3-disc-dumper"; homepage = "https://github.com/13xforever/ps3-disc-dumper";
description = "A handy utility to make decrypted PS3 disc dumps"; description = "A handy utility to make decrypted PS3 disc dumps";