From 928293691a5e764288673a2af23b3665d7a2b1d8 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Fri, 8 Aug 2025 22:59:42 -0300 Subject: [PATCH 1/4] dotnet-hook: fix incorrect use of --runtime in pack --- .../dotnet/build-dotnet-module/hook/dotnet-hook.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh index 0b12e9fd4d50..7da8ca6d33f3 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh @@ -357,7 +357,7 @@ dotnetInstallPhase() { local -r projectFile="${1-}" for runtimeId in "${runtimeIds[@]}"; do - runtimeIdFlags=() + local runtimeIdFlags=() if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then runtimeIdFlags+=("--runtime" "$runtimeId") fi @@ -381,6 +381,11 @@ dotnetInstallPhase() { local -r projectFile="${1-}" for runtimeId in "${runtimeIds[@]}"; do + local runtimeIdFlags=() + if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then + runtimeIdFlags+=("--runtime" "$runtimeId") + fi + dotnet pack ${1+"$projectFile"} \ -maxcpucount:"$maxCpuFlag" \ -p:ContinuousIntegrationBuild=true \ @@ -390,7 +395,7 @@ dotnetInstallPhase() { --configuration "$dotnetBuildType" \ --no-restore \ --no-build \ - --runtime "$runtimeId" \ + "${runtimeIdFlags[@]}" \ "${flags[@]}" \ "${packFlags[@]}" done From fe10ae4b0f5de47b39d040fe4f4ca528cf512fe4 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Wed, 25 Jun 2025 10:09:04 -0300 Subject: [PATCH 2/4] buildDotnet module: work around broken --runtime in dotnet pack --- .../dotnet/build-dotnet-module/hook/dotnet-hook.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh index 7da8ca6d33f3..da277091feb3 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh @@ -384,6 +384,9 @@ dotnetInstallPhase() { local runtimeIdFlags=() if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then runtimeIdFlags+=("--runtime" "$runtimeId") + # set RuntimeIdentifier because --runtime is broken: + # https://github.com/dotnet/sdk/issues/13983 + runtimeIdFlags+=(-p:RuntimeIdentifier="$runtimeId") fi dotnet pack ${1+"$projectFile"} \ From 83117ab9302e9b94e9c6ca3afe194dd50d5bbed9 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Mon, 4 Aug 2025 19:13:23 -0300 Subject: [PATCH 3/4] ArchiSteamFarm: publish plugins with dotnetInstallPhase --- .../misc/ArchiSteamFarm/default.nix | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/pkgs/applications/misc/ArchiSteamFarm/default.nix b/pkgs/applications/misc/ArchiSteamFarm/default.nix index 435e793a1578..7609f3db64f5 100644 --- a/pkgs/applications/misc/ArchiSteamFarm/default.nix +++ b/pkgs/applications/misc/ArchiSteamFarm/default.nix @@ -9,6 +9,14 @@ callPackage, }: +let + plugins = [ + "ArchiSteamFarm.OfficialPlugins.ItemsMatcher" + "ArchiSteamFarm.OfficialPlugins.MobileAuthenticator" + "ArchiSteamFarm.OfficialPlugins.Monitoring" + "ArchiSteamFarm.OfficialPlugins.SteamTokenDumper" + ]; +in buildDotnetModule rec { pname = "ArchiSteamFarm"; # nixpkgs-update: no auto update @@ -26,7 +34,12 @@ buildDotnetModule rec { nugetDeps = ./deps.json; - projectFile = "ArchiSteamFarm.sln"; + projectFile = [ + "ArchiSteamFarm" + ] + ++ plugins; + testProjectFile = "ArchiSteamFarm.Tests"; + executable = "ArchiSteamFarm"; enableParallelBuilding = false; @@ -50,7 +63,7 @@ buildDotnetModule rec { doCheck = true; - preInstall = '' + installPhase = '' dotnetProjectFiles=(ArchiSteamFarm) # A mutable path, with this directory tree must be set. By default, this would point at the nix store causing errors. @@ -58,20 +71,19 @@ buildDotnetModule rec { --run 'mkdir -p ~/.config/archisteamfarm/{config,logs,plugins}' --set "ASF_PATH" "~/.config/archisteamfarm" ) - ''; - postInstall = '' + dotnetInstallPhase + buildPlugin() { echo "Publishing plugin $1" - dotnet publish $1 -p:ContinuousIntegrationBuild=true -p:Deterministic=true \ - --output $out/lib/ArchiSteamFarm/plugins/$1 --configuration Release \ - $dotnetFlags $dotnetInstallFlags + dotnetProjectFiles=("$1") + dotnetInstallPath="$out/lib/ArchiSteamFarm/plugins/$1" + dotnetInstallPhase } - buildPlugin ArchiSteamFarm.OfficialPlugins.ItemsMatcher - buildPlugin ArchiSteamFarm.OfficialPlugins.MobileAuthenticator - buildPlugin ArchiSteamFarm.OfficialPlugins.Monitoring - buildPlugin ArchiSteamFarm.OfficialPlugins.SteamTokenDumper + '' + + lib.concatMapStrings (p: "buildPlugin ${p}\n") plugins + + '' chmod +x $out/lib/ArchiSteamFarm/ArchiSteamFarm.dll wrapDotnetProgram $out/lib/ArchiSteamFarm/ArchiSteamFarm.dll $out/bin/ArchiSteamFarm From 4910a4d3948dcf9df88d8c24cf1a2513e59c1a14 Mon Sep 17 00:00:00 2001 From: David McFarland Date: Wed, 25 Jun 2025 10:04:13 -0300 Subject: [PATCH 4/4] buildDotnetModule: always use --runtime when there's no solution file --- .../build-dotnet-module/hook/dotnet-hook.sh | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh b/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh index da277091feb3..5491d5d54e7e 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh +++ b/pkgs/build-support/dotnet/build-dotnet-module/hook/dotnet-hook.sh @@ -1,5 +1,9 @@ # shellcheck shell=bash +_dotnetIsSolution() { + dotnet sln ${1:+"$1"} list 2>/dev/null +} + dotnetConfigurePhase() { echo "Executing dotnetConfigureHook" @@ -108,9 +112,12 @@ dotnetBuildPhase() { dotnetBuild() { local -r projectFile="${1-}" + local useRuntime= + _dotnetIsSolution "$projectFile" || useRuntime=1 + for runtimeId in "${runtimeIds[@]}"; do local runtimeIdFlags=() - if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then + if [[ -n $useRuntime ]]; then runtimeIdFlags+=("--runtime" "$runtimeId") fi @@ -188,9 +195,12 @@ dotnetCheckPhase() { local projectFile runtimeId for projectFile in "${testProjectFiles[@]-${projectFiles[@]}}"; do + local useRuntime= + _dotnetIsSolution "$projectFile" || useRuntime=1 + for runtimeId in "${runtimeIds[@]}"; do local runtimeIdFlags=() - if [[ $projectFile == *.csproj ]]; then + if [[ -n $useRuntime ]]; then runtimeIdFlags=("--runtime" "$runtimeId") fi @@ -356,9 +366,12 @@ dotnetInstallPhase() { dotnetPublish() { local -r projectFile="${1-}" + local useRuntime= + _dotnetIsSolution "$projectFile" || useRuntime=1 + for runtimeId in "${runtimeIds[@]}"; do local runtimeIdFlags=() - if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then + if [[ -n $useRuntime ]]; then runtimeIdFlags+=("--runtime" "$runtimeId") fi @@ -380,9 +393,12 @@ dotnetInstallPhase() { dotnetPack() { local -r projectFile="${1-}" + local useRuntime= + _dotnetIsSolution "$projectFile" || useRuntime=1 + for runtimeId in "${runtimeIds[@]}"; do local runtimeIdFlags=() - if [[ $projectFile == *.csproj || -n ${dotnetSelfContainedBuild-} ]]; then + if [[ -n $useRuntime ]]; then runtimeIdFlags+=("--runtime" "$runtimeId") # set RuntimeIdentifier because --runtime is broken: # https://github.com/dotnet/sdk/issues/13983