about summary refs log tree commit diff
path: root/pkgs/development/compilers/dotnet/default.nix
blob: 69cd17ec6244a7f3b9115fd735b02c4a2fa6d04d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
  How to combine packages for use in development:
  dotnetCombined = with dotnetCorePackages; combinePackages [ sdk_6_0 aspnetcore_7_0 ];

  Hashes and urls are retrieved from:
  https://dotnet.microsoft.com/download/dotnet
*/
{
  lib,
  config,
  recurseIntoAttrs,
  generateSplicesForMkScope,
  makeScopeWithSplicing',
}:

makeScopeWithSplicing' {
  otherSplices = generateSplicesForMkScope "dotnetCorePackages";
  f = (
    self:
    let
      callPackage = self.callPackage;

      fetchNupkg = callPackage ../../../build-support/dotnet/fetch-nupkg { };

      buildDotnet = attrs: callPackage (import ./build-dotnet.nix attrs) { };
      buildAttrs = {
        inherit fetchNupkg;
        buildAspNetCore = attrs: buildDotnet (attrs // { type = "aspnetcore"; });
        buildNetRuntime = attrs: buildDotnet (attrs // { type = "runtime"; });
        buildNetSdk = attrs: buildDotnet (attrs // { type = "sdk"; });
      };

      ## Files in versions/ are generated automatically by update.sh ##
      dotnet_6_0 = import ./versions/6.0.nix buildAttrs;
      dotnet_7_0 = import ./versions/7.0.nix buildAttrs;
      dotnet_8_0 = import ./versions/8.0.nix buildAttrs;
      dotnet_9_0 = import ./versions/9.0.nix buildAttrs;

      runtimeIdentifierMap = {
        "x86_64-linux" = "linux-x64";
        "aarch64-linux" = "linux-arm64";
        "x86_64-darwin" = "osx-x64";
        "aarch64-darwin" = "osx-arm64";
        "x86_64-windows" = "win-x64";
        "i686-windows" = "win-x86";
      };

    in
    {
      inherit callPackage fetchNupkg;

      # Convert a "stdenv.hostPlatform.system" to a dotnet RID
      systemToDotnetRid =
        system: runtimeIdentifierMap.${system} or (throw "unsupported platform ${system}");

      combinePackages = attrs: callPackage (import ./combine-packages.nix attrs) { };

      patchNupkgs = callPackage ./patch-nupkgs.nix { };
      nugetPackageHook = callPackage ./nuget-package-hook.nix { };

      buildDotnetModule = callPackage ../../../build-support/dotnet/build-dotnet-module { };
      buildDotnetGlobalTool = callPackage ../../../build-support/dotnet/build-dotnet-global-tool { };

      mkNugetSource = callPackage ../../../build-support/dotnet/make-nuget-source { };
      mkNugetDeps = callPackage ../../../build-support/dotnet/make-nuget-deps { };
      addNuGetDeps = callPackage ../../../build-support/dotnet/add-nuget-deps { };

      dotnet_8 = recurseIntoAttrs (callPackage ./8 { bootstrapSdk = dotnet_8_0.sdk_8_0_1xx; });
      dotnet_9 = recurseIntoAttrs (callPackage ./9 { });
    }
    // lib.optionalAttrs config.allowAliases {
      # EOL
      sdk_2_1 = throw "Dotnet SDK 2.1 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
      sdk_2_2 = throw "Dotnet SDK 2.2 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
      sdk_3_0 = throw "Dotnet SDK 3.0 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
      sdk_3_1 = throw "Dotnet SDK 3.1 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
      sdk_5_0 = throw "Dotnet SDK 5.0 is EOL, please use 6.0 (LTS) or 7.0 (Current)";
    }
    // dotnet_6_0
    // dotnet_7_0
    // dotnet_8_0
    // dotnet_9_0
  );
}