diff options
author | mdarocha <git@mdarocha.pl> | 2023-06-20 17:19:30 +0200 |
---|---|---|
committer | mdarocha <git@mdarocha.pl> | 2023-06-20 17:20:51 +0200 |
commit | 6c639e869c1fa420c707724eeba107a5017df0d2 (patch) | |
tree | eb6f57d8a137f71881413fdeaf4bc16c771b5511 /pkgs/build-support | |
parent | 2c9ecd1f0400076a4d6b2193ad468ff0a7e7fdc5 (diff) |
buildDotnetModule: tweaks to support paket
Projects that use paket, and have it setup so that it's executed transparently during "dotnet restore" as a dotnet tool should now work.
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/dotnet/build-dotnet-module/default.nix | 7 | ||||
-rw-r--r-- | pkgs/build-support/dotnet/build-dotnet-module/hooks/dotnet-configure-hook.sh | 10 |
2 files changed, 13 insertions, 4 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix index 07e62835956fa..bfd249a872b13 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix @@ -12,6 +12,7 @@ , nuget-to-nix , cacert , coreutils +, runtimeShellPackage }: { name ? "${args.pname}-${args.version}" @@ -183,7 +184,7 @@ stdenvNoCC.mkDerivation (args // { writeShellScript "fetch-${pname}-deps" '' set -euo pipefail - export PATH="${lib.makeBinPath [ coreutils dotnet-sdk (nuget-to-nix.override { inherit dotnet-sdk; }) ]}" + export PATH="${lib.makeBinPath [ coreutils runtimeShellPackage dotnet-sdk (nuget-to-nix.override { inherit dotnet-sdk; }) ]}" for arg in "$@"; do case "$arg" in @@ -262,7 +263,7 @@ stdenvNoCC.mkDerivation (args // { echo "Restoring project..." ${dotnet-sdk}/bin/dotnet tool restore - mv $HOME/.nuget/packages/* $tmp/nuget_pkgs || true + cp -r $HOME/.nuget/packages/* $tmp/nuget_pkgs || true for rid in "${lib.concatStringsSep "\" \"" runtimeIds}"; do (( ''${#projectFiles[@]} == 0 )) && dotnetRestore "" "$rid" @@ -271,6 +272,8 @@ stdenvNoCC.mkDerivation (args // { dotnetRestore "$project" "$rid" done done + # Second copy, makes sure packages restored by ie. paket are included + cp -r $HOME/.nuget/packages/* $tmp/nuget_pkgs || true echo "Succesfully restored project" 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 0e502fe6a14d0..20e353e2b418f 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 @@ -25,8 +25,6 @@ dotnetConfigureHook() { ${dotnetFlags[@]} } - (( "${#projectFile[@]}" == 0 )) && dotnetRestore - # Generate a NuGet.config file to make sure everything, # including things like <Sdk /> dependencies, is restored from the proper source cat <<EOF > "./NuGet.config" @@ -39,8 +37,16 @@ cat <<EOF > "./NuGet.config" </configuration> EOF + # Patch paket.dependencies and paket.lock (if found) to use the proper source. This ensures + # paket restore works correctly + # We use + instead of / in sed to avoid problems with slashes + find -name paket.dependencies -exec sed -i 's+source .*+source @nugetSource@/lib+g' {} \; + find -name paket.lock -exec sed -i 's+remote:.*+remote: @nugetSource@/lib+g' {} \; + env dotnet tool restore --add-source "@nugetSource@/lib" + (( "${#projectFile[@]}" == 0 )) && dotnetRestore + for project in ${projectFile[@]} ${testProjectFile[@]-}; do dotnetRestore "$project" done |