From 5fb3301dad4ff5c41342d7c961bd4590e343e332 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Tue, 2 Jan 2024 10:51:30 +0100 Subject: [PATCH 1/2] mkNugetSource: Remove meta.licenses attribute - It's useless. The correct attribute name would be `license` and not `licenses`. Meaning setting this never did anything useful. - It used IFD in its implementation, meaning to know what the licenses of a nuget source are, you first had to build that nuget source. This defeats the point of having license checks in the first place. - IFD is not allowed by the nixpkgs CI and build farm anyway. --- .../dotnet/make-nuget-source/default.nix | 41 +++++++------------ 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/pkgs/build-support/dotnet/make-nuget-source/default.nix b/pkgs/build-support/dotnet/make-nuget-source/default.nix index 48de65e8a881..6964627a8398 100644 --- a/pkgs/build-support/dotnet/make-nuget-source/default.nix +++ b/pkgs/build-support/dotnet/make-nuget-source/default.nix @@ -5,34 +5,23 @@ , deps ? [] }: -let - nuget-source = stdenvNoCC.mkDerivation { - inherit name; +stdenvNoCC.mkDerivation { + inherit name; - nativeBuildInputs = [ python3 ]; + nativeBuildInputs = [ python3 ]; - buildCommand = '' - mkdir -p $out/{lib,share} + buildCommand = '' + mkdir -p $out/{lib,share} - # use -L to follow symbolic links. When `projectReferences` is used in - # buildDotnetModule, one of the deps will be a symlink farm. - find -L ${lib.concatStringsSep " " deps} -type f -name '*.nupkg' -exec \ - ln -s '{}' -t $out/lib ';' + # use -L to follow symbolic links. When `projectReferences` is used in + # buildDotnetModule, one of the deps will be a symlink farm. + find -L ${lib.concatStringsSep " " deps} -type f -name '*.nupkg' -exec \ + ln -s '{}' -t $out/lib ';' - # Generates a list of all licenses' spdx ids, if available. - # Note that this currently ignores any license provided in plain text (e.g. "LICENSE.txt") - python ${./extract-licenses-from-nupkgs.py} $out/lib > $out/share/licenses - ''; + # Generates a list of all licenses' spdx ids, if available. + # Note that this currently ignores any license provided in plain text (e.g. "LICENSE.txt") + python ${./extract-licenses-from-nupkgs.py} $out/lib > $out/share/licenses + ''; - meta.description = description; - } // { # We need data from `$out` for `meta`, so we have to use overrides as to not hit infinite recursion. - meta = nuget-source.meta // { - licenses = let - # TODO: avoid IFD - depLicenses = lib.splitString "\n" (builtins.readFile "${nuget-source}/share/licenses"); - in lib.flatten (lib.forEach depLicenses (spdx: - lib.optionals (spdx != "") (lib.getLicenseFromSpdxId spdx) - )); - }; - }; -in nuget-source + meta.description = description; +} From 928d66083e5bae2f4d2ef622a2d53b3ac8760297 Mon Sep 17 00:00:00 2001 From: Raphael Robatsch Date: Tue, 2 Jan 2024 11:01:41 +0100 Subject: [PATCH 2/2] mkNugetSource: Allow passing arbitrary stdenv.mkDerivation attrs This allows things such as mkNugetSource { name = "foo-nuget-source"; deps = [ ... ]; meta = { hydraPlatforms = [ ]; }; } --- pkgs/build-support/dotnet/make-nuget-source/default.nix | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/pkgs/build-support/dotnet/make-nuget-source/default.nix b/pkgs/build-support/dotnet/make-nuget-source/default.nix index 6964627a8398..4cf9c1a7412a 100644 --- a/pkgs/build-support/dotnet/make-nuget-source/default.nix +++ b/pkgs/build-support/dotnet/make-nuget-source/default.nix @@ -3,9 +3,10 @@ { name , description ? "" , deps ? [] -}: +, ... +}@args: -stdenvNoCC.mkDerivation { +stdenvNoCC.mkDerivation (lib.recursiveUpdate { inherit name; nativeBuildInputs = [ python3 ]; @@ -24,4 +25,4 @@ stdenvNoCC.mkDerivation { ''; meta.description = description; -} +} (removeAttrs args [ "name" "description" "deps" ]))