about summary refs log tree commit diff
path: root/pkgs/build-support/dotnet
diff options
context:
space:
mode:
authormdarocha <git@mdarocha.pl>2023-03-19 20:38:24 +0100
committermdarocha <git@mdarocha.pl>2023-03-19 20:53:39 +0100
commitd093086a2b20a4b2183e85ee86d663f54dcebfef (patch)
treef45f7dd750b01341f790419130e6b66cf4f58270 /pkgs/build-support/dotnet
parent26ff0e4a27e9a6c23d4aba5eb180f397f21cf6ae (diff)
buildDotnetModule: add support for using combinePackages as dotnet-sdk
This allows packages that require several dotnet versions to build (like
BeatSaberModManager) to properly depend on the dotnet-sdk specific deps.
This in turns avoids having to regenerate the deps of those packages
after each dotnet-sdk update.

This also changes nuget-to-nix to accept a file with a list of
exclusions instead of a folder.
Diffstat (limited to 'pkgs/build-support/dotnet')
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/default.nix17
-rwxr-xr-xpkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh7
2 files changed, 16 insertions, 8 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
index 311eb2b293e5e..32e8cbd2b1ad1 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix
+++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
@@ -121,11 +121,13 @@ let
   # this contains all the nuget packages that are implicitly referenced by the dotnet
   # build system. having them as separate deps allows us to avoid having to regenerate
   # a packages dependencies when the dotnet-sdk version changes
-  sdkDeps = dotnet-sdk.packages;
+  sdkDeps = lib.lists.flatten [ dotnet-sdk.packages ];
 
-  sdkSource = mkNugetSource {
-    name = "dotnet-sdk-${dotnet-sdk.version}-source";
-    deps = [ sdkDeps ];
+  sdkSource = let
+    version = dotnet-sdk.version or (lib.concatStringsSep "-" dotnet-sdk.versions);
+  in mkNugetSource {
+    name = "dotnet-sdk-${version}-source";
+    deps = sdkDeps;
   };
 
   nuget-source = symlinkJoin {
@@ -271,7 +273,12 @@ stdenvNoCC.mkDerivation (args // {
 
         echo "Writing lockfile..."
         echo -e "# This file was automatically generated by passthru.fetch-deps.\n# Please dont edit it manually, your changes might get overwritten!\n" > "$depsFile"
-        nuget-to-nix "$tmp/nuget_pkgs" "${sdkDeps}" >> "$depsFile"
+
+        excluded_sources="${lib.concatStringsSep " " sdkDeps}"
+        for excluded_source in ''${excluded_sources[@]}; do
+          ls "$excluded_source" >> "$tmp/excluded_list"
+        done
+        nuget-to-nix "$tmp/nuget_pkgs" "$tmp/excluded_list" >> "$depsFile"
         echo "Succesfully wrote lockfile to $depsFile"
       '';
   } // args.passthru or { };
diff --git a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
index 390c96751facd..ce2a7070ea31e 100755
--- a/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
+++ b/pkgs/build-support/dotnet/nuget-to-nix/nuget-to-nix.sh
@@ -7,14 +7,15 @@ export PATH="@binPath@"
 export LC_ALL=C
 
 if [ $# -eq 0 ]; then
-  >&2 echo "Usage: $0 <packages directory> [path to excluded package source] > deps.nix"
+  >&2 echo "Usage: $0 <packages directory> [path to a file with a list of excluded packages] > deps.nix"
   exit 1
 fi
 
 pkgs=$1
 tmp=$(realpath "$(mktemp -td nuget-to-nix.XXXXXX)")
 trap 'rm -r "$tmp"' EXIT
-excluded_source=$(realpath "${2:-$tmp/empty}")
+
+excluded_list=$(realpath "${2:-/dev/null}")
 
 export DOTNET_NOLOGO=1
 export DOTNET_CLI_TELEMETRY_OPTOUT=1
@@ -37,7 +38,7 @@ for package in *; do
   for version in *; do
     id=$(xq -r .package.metadata.id "$version/$package".nuspec)
 
-    if [[ -e "$excluded_source/$id.$version".nupkg ]]; then
+    if grep -qxF "$id.$version.nupkg" "$excluded_list"; then
       continue
     fi