summary refs log tree commit diff
path: root/pkgs/build-support/dotnet
diff options
context:
space:
mode:
authorLassulus <github@lassul.us>2022-03-02 20:05:18 +0100
committerGitHub <noreply@github.com>2022-03-02 20:05:18 +0100
commit1d8b13942b0c941c112c244747f5a5fefd8cb7b2 (patch)
tree4a6fcd3440c90003bb9c59c7d1d4c81a8a726da3 /pkgs/build-support/dotnet
parent2e5f265fdb2d0df2023864e56b5bc54ef9f67fbe (diff)
parent81998d0a1ded8a309bb16d4c73ab30e7b78f0c12 (diff)
downloadnixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.tar
nixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.tar.gz
nixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.tar.bz2
nixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.tar.lz
nixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.tar.xz
nixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.tar.zst
nixpkgs-1d8b13942b0c941c112c244747f5a5fefd8cb7b2.zip
Merge pull request #161504 from moinessim/writefsharp
writers: Add writeFSharp and makeFSharpWriter functions to writers
Diffstat (limited to 'pkgs/build-support/dotnet')
-rw-r--r--pkgs/build-support/dotnet/build-dotnet-module/default.nix39
-rw-r--r--pkgs/build-support/dotnet/make-nuget-deps/default.nix9
-rw-r--r--pkgs/build-support/dotnet/make-nuget-source/default.nix30
3 files changed, 45 insertions, 33 deletions
diff --git a/pkgs/build-support/dotnet/build-dotnet-module/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
index e721b59decb..e3762327a10 100644
--- a/pkgs/build-support/dotnet/build-dotnet-module/default.nix
+++ b/pkgs/build-support/dotnet/build-dotnet-module/default.nix
@@ -1,4 +1,4 @@
-{ lib, stdenvNoCC, linkFarmFromDrvs, callPackage, nuget-to-nix, writeScript, makeWrapper, fetchurl, xml2, dotnetCorePackages, dotnetPackages, cacert }:
+{ lib, stdenvNoCC, linkFarmFromDrvs, callPackage, nuget-to-nix, writeScript, makeWrapper, fetchurl, xml2, dotnetCorePackages, dotnetPackages, mkNugetSource, mkNugetDeps, cacert }:
 
 { name ? "${args.pname}-${args.version}"
 , pname ? name
@@ -74,40 +74,13 @@ let
     inherit dotnet-sdk dotnet-test-sdk disabledTests nuget-source dotnet-runtime runtimeDeps buildType;
   }) dotnetConfigureHook dotnetBuildHook dotnetCheckHook dotnetInstallHook dotnetFixupHook;
 
-  _nugetDeps = linkFarmFromDrvs "${name}-nuget-deps" (import nugetDeps {
-    fetchNuGet = { pname, version, sha256 }: fetchurl {
-      name = "${pname}-${version}.nupkg";
-      url = "https://www.nuget.org/api/v2/package/${pname}/${version}";
-      inherit sha256;
-    };
-  });
+  _nugetDeps = mkNugetDeps { name = "${name}-nuget-deps"; nugetDeps = import nugetDeps; };
   _localDeps = linkFarmFromDrvs "${name}-local-nuget-deps" projectReferences;
 
-  nuget-source = stdenvNoCC.mkDerivation rec {
-    name = "${pname}-nuget-source";
-    meta.description = "A Nuget source with the dependencies for ${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"
-      ${lib.optionalString (projectReferences != [])
-        "nuget init \"${_localDeps}\" \"$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
-    )));
+  nuget-source = mkNugetSource {
+    name = "${args.pname}-nuget-source";
+    description = "A Nuget source with the dependencies for ${args.pname}";
+    deps = [ _nugetDeps _localDeps ];
   };
 
 in stdenvNoCC.mkDerivation (args // {
diff --git a/pkgs/build-support/dotnet/make-nuget-deps/default.nix b/pkgs/build-support/dotnet/make-nuget-deps/default.nix
new file mode 100644
index 00000000000..75178d5b779
--- /dev/null
+++ b/pkgs/build-support/dotnet/make-nuget-deps/default.nix
@@ -0,0 +1,9 @@
+{ linkFarmFromDrvs, fetchurl }:
+{ name, nugetDeps }:
+  linkFarmFromDrvs "${name}-nuget-deps" (nugetDeps {
+    fetchNuGet = { pname, version, sha256 }: fetchurl {
+      name = "${pname}-${version}.nupkg";
+      url = "https://www.nuget.org/api/v2/package/${pname}/${version}";
+      inherit sha256;
+    };
+  })
diff --git a/pkgs/build-support/dotnet/make-nuget-source/default.nix b/pkgs/build-support/dotnet/make-nuget-source/default.nix
new file mode 100644
index 00000000000..0690a05aa2b
--- /dev/null
+++ b/pkgs/build-support/dotnet/make-nuget-source/default.nix
@@ -0,0 +1,30 @@
+{ 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