dotnet-sdk-setup-hook: move nuget configuration from dotnetBuildModule

This commit is contained in:
David McFarland 2024-09-07 23:26:08 -03:00
parent 60eb0db2ab
commit 773cc0de74
3 changed files with 18 additions and 13 deletions

View File

@ -38,18 +38,6 @@ dotnetConfigureHook() {
done
}
find -iname nuget.config -print0 | while IFS= read -rd "" config; do
if [[ -n "${keepNugetConfig-}" ]]; then
# If we're keeping the existing configs, we'll add _nix everywhere,
# in case sources are cleared.
dotnet nuget add source "$nugetSource" -n _nix --configfile "$config"
else
# This will allow everything to fall through to our config in the
# build root. Deleting them causes some build failures.
xq -xi '.configuration={}' "$config"
fi
done
if [[ -f .config/dotnet-tools.json || -f dotnet-tools.json ]]; then
dotnet tool restore
fi

View File

@ -17,6 +17,7 @@
, lndir
, substituteAll
, nugetPackageHook
, xmlstarlet
}: type: args: stdenv.mkDerivation (finalAttrs: args // {
doInstallCheck = true;
@ -30,7 +31,7 @@
./dotnet-setup-hook.sh
] ++ lib.optional (type == "sdk") (substituteAll {
src = ./dotnet-sdk-setup-hook.sh;
inherit lndir;
inherit lndir xmlstarlet;
});
propagatedBuildInputs =

View File

@ -42,6 +42,7 @@ createNugetDirs() {
fi
dotnet nuget add source "$nugetSource" -n _nix
nugetConfig=$PWD/nuget.config
}
configureNuget() {
@ -57,6 +58,21 @@ configureNuget() {
fi
done
find -iname nuget.config -print0 | while IFS= read -rd "" config; do
if [[ -n ${keepNugetConfig-} ]]; then
# If we're keeping the existing configs, we'll add _nix everywhere,
# in case sources are cleared.
dotnet nuget add source "$nugetSource" -n _nix --configfile "$config"
else
# This will allow everything to fall through to our config in the
# build root. Deleting them causes some build failures.
@xmlstarlet@/bin/xmlstarlet \
ed --inplace \
-d '//configuration/*' \
"$config"
fi
done
if [[ -n ${linkNugetPackages-}
|| -f .config/dotnet-tools.json
|| -f dotnet-tools.json