summary refs log tree commit diff
path: root/pkgs/build-support/dotnet
diff options
context:
space:
mode:
authorMoises Nessim <moises.nessim@topmanage.com>2022-02-28 17:40:43 -0500
committerMoises Nessim <moises.nessim@topmanage.com>2022-02-28 17:40:43 -0500
commit81998d0a1ded8a309bb16d4c73ab30e7b78f0c12 (patch)
tree11ba9e9a78b19be6c1d43a4cc78702f12c0b22e1 /pkgs/build-support/dotnet
parentb007a4e702d73a53b3dee23dadabb2573cac59ce (diff)
downloadnixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.tar
nixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.tar.gz
nixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.tar.bz2
nixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.tar.lz
nixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.tar.xz
nixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.tar.zst
nixpkgs-81998d0a1ded8a309bb16d4c73ab30e7b78f0c12.zip
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
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 d3561282d3f..344a7acccc6 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