about summary refs log tree commit diff
path: root/pkgs/development/compilers/dotnet/packages.nix
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/compilers/dotnet/packages.nix')
-rw-r--r--pkgs/development/compilers/dotnet/packages.nix153
1 files changed, 109 insertions, 44 deletions
diff --git a/pkgs/development/compilers/dotnet/packages.nix b/pkgs/development/compilers/dotnet/packages.nix
index 801896f38625..b32bf3f2d9cf 100644
--- a/pkgs/development/compilers/dotnet/packages.nix
+++ b/pkgs/development/compilers/dotnet/packages.nix
@@ -1,19 +1,100 @@
-{ stdenv
-, callPackage
-, vmr
-, xmlstarlet
-, strip-nondeterminism
-, zip
+{
+  stdenvNoCC,
+  lib,
+  callPackage,
+  vmr,
+  xmlstarlet,
+  strip-nondeterminism,
+  zip,
+  nugetPackageHook,
+  baseName ? "dotnet",
+  fallbackTargetPackages ? { },
 }:
 
 let
-  mkCommon = callPackage ./common.nix {};
+  mkCommon = callPackage ./common.nix { };
   inherit (vmr) targetRid releaseManifest;
 
-in {
-  inherit vmr;
+  # TODO: do this properly
+  hostRid = targetRid;
+
+  mkPackage =
+    pname: version:
+    stdenvNoCC.mkDerivation {
+      inherit pname version;
+
+      src = vmr;
+      dontUnpack = true;
+
+      nativeBuildInputs = [
+        xmlstarlet
+        nugetPackageHook
+      ];
+
+      installPhase = ''
+        runHook preInstall
+
+        mkdir -p "$out"
+
+        pushd "$src"/Private.SourceBuilt.Artifacts.*.${targetRid}
+        pushd ${pname}.${version}.nupkg
+
+        xmlstarlet \
+          sel -t \
+          -m /_:package/_:metadata \
+          -v _:id -nl \
+          -v _:version -nl \
+          *.nuspec | (
+          read id
+          read version
+          id=''${id,,}
+          version=''${version,,}
+          mkdir -p "$out"/share/nuget/packages/"$id"
+          cp -r . "$out"/share/nuget/packages/"$id"/"$version"
+          chmod +w "$out"/share/nuget/packages/"$id"/"$version"
+          echo {} > "$out"/share/nuget/packages/"$id"/"$version"/.nupkg.metadata
+        )
+
+        popd
+        popd
+
+        runHook postInstall
+      '';
+    };
+
+  packages =
+    [
+      (mkPackage "Microsoft.AspNetCore.App.Ref" aspnetcore.version)
+      (mkPackage "Microsoft.NETCore.DotNetAppHost" runtime.version)
+      (mkPackage "Microsoft.NETCore.App.Ref" runtime.version)
+      (mkPackage "Microsoft.DotNet.ILCompiler" runtime.version)
+      (mkPackage "Microsoft.NET.ILLink.Tasks" runtime.version)
+      (mkPackage "Microsoft.NETCore.App.Crossgen2.${hostRid}" runtime.version)
+      (mkPackage "runtime.${hostRid}.Microsoft.DotNet.ILCompiler" runtime.version)
+    ]
+    ++ lib.optionals (lib.versionOlder runtime.version "9") [
+      (mkPackage "Microsoft.NETCore.DotNetHost" runtime.version)
+      (mkPackage "Microsoft.NETCore.DotNetHostPolicy" runtime.version)
+      (mkPackage "Microsoft.NETCore.DotNetHostResolver" runtime.version)
+    ];
+
+  targetPackages = fallbackTargetPackages // {
+    ${targetRid} =
+      [
+        (mkPackage "Microsoft.AspNetCore.App.Runtime.${targetRid}" aspnetcore.version)
+        (mkPackage "Microsoft.NETCore.App.Host.${targetRid}" runtime.version)
+        (mkPackage "Microsoft.NETCore.App.Runtime.${targetRid}" runtime.version)
+        (mkPackage "runtime.${targetRid}.Microsoft.NETCore.DotNetAppHost" runtime.version)
+      ]
+      ++ lib.optionals (lib.versionOlder runtime.version "9") [
+        (mkPackage "runtime.${targetRid}.Microsoft.NETCore.DotNetHost" runtime.version)
+        (mkPackage "runtime.${targetRid}.Microsoft.NETCore.DotNetHostPolicy" runtime.version)
+        (mkPackage "runtime.${targetRid}.Microsoft.NETCore.DotNetHostResolver" runtime.version)
+      ];
+  };
+
   sdk = mkCommon "sdk" rec {
-    pname = "dotnet-sdk";
+    pname = "${baseName}-sdk";
     version = releaseManifest.sdkVersion;
 
     src = vmr;
@@ -25,7 +106,10 @@ in {
       zip
     ];
 
-    outputs = [ "out" "packages" "artifacts" ];
+    outputs = [
+      "out"
+      "artifacts"
+    ];
 
     installPhase = ''
       runHook preInstall
@@ -35,42 +119,12 @@ in {
       mkdir "$out"/bin
       ln -s "$out"/dotnet "$out"/bin/dotnet
 
-      mkdir -p "$packages" "$artifacts"
+      mkdir -p "$artifacts"
       cp -r "$src"/Private.SourceBuilt.Artifacts.*.${targetRid}/* "$artifacts"/
       chmod +w -R "$artifacts"
 
       local package
 
-      for package in "$artifacts"/*.nupkg; do
-        local copy
-        case "$(basename "$package")" in
-          *Microsoft.NET.* | \
-          *Microsoft.ILLink.* | \
-          *Microsoft.Tasks.* | \
-          *Microsoft.NETCore.* | \
-          *Microsoft.DotNet.* | \
-          *Microsoft.AspNetCore.*) copy=1 ;;
-          *) copy= ;;
-        esac
-        if [[ -n $copy ]]; then
-          echo copying "$package" to packages
-          xmlstarlet \
-            sel -t \
-            -m /_:package/_:metadata \
-            -v _:id -nl \
-            -v _:version -nl \
-            "$package"/*.nuspec | (
-            read id
-            read version
-            id=''${id,,}
-            version=''${version,,}
-            mkdir -p "$packages"/share/nuget/packages/"$id"
-            cp -r "$package" "$packages"/share/nuget/packages/"$id"/"$version"
-            echo {} > "$packages"/share/nuget/packages/"$id"/"$version"/.nupkg.metadata
-          )
-        fi
-      done
-
       for package in "$artifacts"/{,SourceBuildReferencePackages/}*.nupkg; do
         echo packing "$package" to artifacts
         (cd "$package" && zip -rq0 "$package.tmp" .)
@@ -84,6 +138,8 @@ in {
 
     passthru = {
       inherit (vmr) icu targetRid hasILCompiler;
+
+      inherit packages targetPackages;
     };
 
     meta = vmr.meta // {
@@ -92,7 +148,7 @@ in {
   };
 
   runtime = mkCommon "runtime" rec {
-    pname = "dotnet-runtime";
+    pname = "${baseName}-runtime";
     version = releaseManifest.runtimeVersion;
 
     src = vmr;
@@ -117,7 +173,7 @@ in {
   };
 
   aspnetcore = mkCommon "aspnetcore" rec {
-    pname = "dotnet-aspnetcore-runtime";
+    pname = "${baseName}-aspnetcore-runtime";
     version = releaseManifest.aspNetCoreVersion or releaseManifest.runtimeVersion;
 
     src = vmr;
@@ -143,4 +199,13 @@ in {
       mainProgram = "dotnet";
     };
   };
+in
+{
+  inherit
+    vmr
+    sdk
+    runtime
+    aspnetcore
+    ;
+
 }