diff options
author | IvarWithoutBones <ivar.scholten@protonmail.com> | 2021-10-26 07:27:02 +0200 |
---|---|---|
committer | Jonathan Ringer <jonringer@users.noreply.github.com> | 2021-10-29 08:27:51 -0700 |
commit | bc193f80c437d2db9b7f2348dfae1e05ea756412 (patch) | |
tree | 1ecdf65c6b07517d0c9983336ef8a4f75c112145 /pkgs/build-support | |
parent | 31b495592feadb2785279988a2d7db6e2bdd7ed2 (diff) |
buildDotnetModule: create nuget source seperately && use stdenvNoCC
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/build-dotnet-module/default.nix | 40 |
1 files changed, 29 insertions, 11 deletions
diff --git a/pkgs/build-support/build-dotnet-module/default.nix b/pkgs/build-support/build-dotnet-module/default.nix index 3701f254d0ca4..b6330b90775c5 100644 --- a/pkgs/build-support/build-dotnet-module/default.nix +++ b/pkgs/build-support/build-dotnet-module/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, makeWrapper, dotnetCorePackages, dotnetPackages, cacert, linkFarmFromDrvs, fetchurl }: +{ lib, stdenvNoCC, linkFarmFromDrvs, makeWrapper, fetchurl, xml2, dotnetCorePackages, dotnetPackages, cacert }: { name ? "${args.pname}-${args.version}" , enableParallelBuilding ? true @@ -50,10 +50,35 @@ let }; }); - package = stdenv.mkDerivation (args // { + nuget-source = stdenvNoCC.mkDerivation rec { + name = "${args.pname}-nuget-source"; + meta.description = "A Nuget source with the dependencies for ${args.pname}"; + + nativeBuildInputs = [ dotnetPackages.Nuget xml2 ]; + buildCommand = '' + export HOME=$(mktemp -d) + mkdir -p $out/{lib,share} + + nuget sources Add -Name nixos -Source "$out/lib" + nuget init "${_nugetDeps}" "$out/lib" + + # Generates a list of all unique licenses' spdx ids. + find "$out/lib" -name "*.nuspec" -exec sh -c \ + "xml2 < {} | grep "license=" | cut -d'=' -f2" \; | sort -u > $out/share/licenses + ''; + } // { # This is done because we need data from `$out` for `meta`. We have to use overrides as to not hit infinite recursion. + meta.licence = let + depLicenses = lib.splitString "\n" (builtins.readFile "${nuget-source}/share/licenses"); + getLicence = spdx: lib.filter (license: license.spdxId or null == spdx) (builtins.attrValues lib.licenses); + in (lib.flatten (lib.forEach depLicenses (spdx: + if (getLicence spdx) != [] then (getLicence spdx) else [] ++ lib.optional (spdx != "") spdx + ))); + }; + + package = stdenvNoCC.mkDerivation (args // { inherit buildType; - nativeBuildInputs = args.nativeBuildInputs or [] ++ [ dotnet-sdk dotnetPackages.Nuget cacert makeWrapper ]; + nativeBuildInputs = args.nativeBuildInputs or [] ++ [ dotnet-sdk cacert makeWrapper ]; # Stripping breaks the executable dontStrip = true; @@ -66,18 +91,11 @@ let export HOME=$(mktemp -d) - nuget sources Add -Name nixos -Source "$PWD/nixos" - nuget init "${_nugetDeps}" "$PWD/nixos" - - # This is required due to https://github.com/NuGet/Home/issues/4413. - mkdir -p $HOME/.nuget/NuGet - cp $HOME/.config/NuGet/NuGet.Config $HOME/.nuget/NuGet - dotnet restore "$projectFile" \ ${lib.optionalString (!enableParallelBuilding) "--disable-parallel"} \ -p:ContinuousIntegrationBuild=true \ -p:Deterministic=true \ - --source "$PWD/nixos" \ + --source "${nuget-source}/lib" \ "''${dotnetRestoreFlags[@]}" \ "''${dotnetFlags[@]}" |