nixpkgs-suyu/pkgs/build-support/dotnet/make-nuget-source/default.nix
Moises Nessim 81998d0a1d Add writeFSharp and makeFSharpWriter functions to writers
Uses fsharp interactive (fsi) to run fsx script

Expose mkNugetSource and mkNugetDeps functions

Use them in writers.writeFSharp and buildDotnetModule

Add tests
2022-02-28 17:40:43 -05:00

30 lines
1.2 KiB
Nix

{ dotnetPackages, lib, xml2, stdenvNoCC }:
{ name, description ? "", deps ? [] }:
let
_nuget-source = stdenvNoCC.mkDerivation rec {
inherit name;
meta.description = description;
nativeBuildInputs = [ dotnetPackages.Nuget xml2 ];
buildCommand = ''
export HOME=$(mktemp -d)
mkdir -p $out/{lib,share}
nuget sources Add -Name nixos -Source "$out/lib"
${ lib.concatMapStringsSep "\n" (dep:
''nuget init "${dep}" "$out/lib"''
) deps }
# 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
)));
};
in _nuget-source