nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1/*
2 How to combine packages for use in development:
3 dotnetCombined = with dotnetCorePackages; combinePackages [ sdk_9_0 aspnetcore_8_0 ];
4
5 Hashes and urls are retrieved from:
6 https://dotnet.microsoft.com/download/dotnet
7*/
8{
9 lib,
10 config,
11 generateSplicesForMkScope,
12 makeScopeWithSplicing',
13 writeScriptBin,
14}:
15
16let
17 pkgs = makeScopeWithSplicing' {
18 otherSplices = generateSplicesForMkScope "dotnetCorePackages";
19 f = (
20 self:
21 let
22 callPackage = self.callPackage;
23
24 fetchNupkg = callPackage ../../../build-support/dotnet/fetch-nupkg { };
25
26 buildDotnet = attrs: callPackage (import ./build-dotnet.nix attrs) { };
27 buildDotnetSdk =
28 version:
29 import version {
30 inherit fetchNupkg;
31 buildAspNetCore = attrs: buildDotnet (attrs // { type = "aspnetcore"; });
32 buildNetRuntime = attrs: buildDotnet (attrs // { type = "runtime"; });
33 buildNetSdk = attrs: buildDotnet (attrs // { type = "sdk"; });
34 };
35
36 ## Files in versions/ are generated automatically by update.sh ##
37 dotnet-bin = lib.mergeAttrsList (
38 map buildDotnetSdk [
39 ./versions/6.0.nix
40 ./versions/7.0.nix
41 ./versions/8.0.nix
42 ./versions/9.0.nix
43 ./versions/10.0.nix
44 ./versions/11.0.nix
45 ]
46 );
47
48 runtimeIdentifierMap = {
49 "x86_64-linux" = "linux-x64";
50 "aarch64-linux" = "linux-arm64";
51 "x86_64-darwin" = "osx-x64";
52 "aarch64-darwin" = "osx-arm64";
53 "x86_64-windows" = "win-x64";
54 "i686-windows" = "win-x86";
55 };
56
57 in
58 lib.optionalAttrs config.allowAliases (
59 {
60 # EOL
61 sdk_2_1 = throw "Dotnet SDK 2.1 is EOL, please use 8.0 (LTS) or 9.0 (Current)";
62 sdk_2_2 = throw "Dotnet SDK 2.2 is EOL, please use 8.0 (LTS) or 9.0 (Current)";
63 sdk_3_0 = throw "Dotnet SDK 3.0 is EOL, please use 8.0 (LTS) or 9.0 (Current)";
64 sdk_3_1 = throw "Dotnet SDK 3.1 is EOL, please use 8.0 (LTS) or 9.0 (Current)";
65 sdk_5_0 = throw "Dotnet SDK 5.0 is EOL, please use 8.0 (LTS) or 9.0 (Current)";
66 }
67 // dotnet-bin
68 )
69 // lib.mapAttrs' (k: v: lib.nameValuePair "${k}-bin" v) dotnet-bin
70 // {
71 inherit callPackage fetchNupkg buildDotnetSdk;
72
73 generate-dotnet-sdk = writeScriptBin "generate-dotnet-sdk" (
74 # Don't include current nixpkgs in the exposed version. We want to make the script runnable without nixpkgs repo.
75 builtins.replaceStrings [ " -I nixpkgs=./." ] [ "" ] (builtins.readFile ./update.sh)
76 );
77
78 # Convert a "stdenv.hostPlatform.system" to a dotnet RID
79 systemToDotnetRid =
80 system: runtimeIdentifierMap.${system} or (throw "unsupported platform ${system}");
81
82 combinePackages = attrs: callPackage (import ./combine-packages.nix attrs) { };
83
84 patchNupkgs = callPackage ./patch-nupkgs.nix { };
85 nugetPackageHook = callPackage ./nuget-package-hook.nix { };
86 autoPatchcilHook = callPackage ../../../build-support/dotnet/auto-patchcil-hook { };
87
88 buildDotnetModule = callPackage ../../../build-support/dotnet/build-dotnet-module { };
89 buildDotnetGlobalTool = callPackage ../../../build-support/dotnet/build-dotnet-global-tool { };
90
91 mkNugetSource = callPackage ../../../build-support/dotnet/make-nuget-source { };
92 mkNugetDeps = callPackage ../../../build-support/dotnet/make-nuget-deps { };
93 addNuGetDeps = callPackage ../../../build-support/dotnet/add-nuget-deps { };
94
95 dotnet_8 = lib.recurseIntoAttrs (callPackage ./8 { });
96 dotnet_9 = lib.recurseIntoAttrs (callPackage ./9 { });
97 dotnet_10 = lib.recurseIntoAttrs (callPackage ./10 { });
98 dotnet_11 = lib.recurseIntoAttrs (callPackage ./11 { });
99 }
100 );
101 };
102
103 # combine an SDK with the runtime/packages from a base SDK
104 combineSdk =
105 base: fallback:
106 if (fallback.runtime.version != base.runtime.version) then
107 throw "combineSdk: unable to combine ${fallback.name} with ${base.name} because runtime versions don't match (${fallback.runtime.version} != ${base.runtime.version})"
108 else if base.meta.broken then
109 fallback
110 else
111 let
112 withBaseRuntimes =
113 if fallback.version == base.version then
114 base.unwrapped
115 else
116 (pkgs.combinePackages [
117 base.runtime
118 base.aspnetcore
119 fallback
120 ]).unwrapped.overrideAttrs
121 (old: {
122 name = fallback.unwrapped.name;
123 # resolve symlinks so DOTNET_ROOT is self-contained
124 postBuild = ''
125 mv "$out"/share/dotnet{,~}
126 cp -Lr "$out"/share/dotnet{~,}
127 rm -r "$out"/share/dotnet~
128 ''
129 + old.postBuild;
130 passthru = old.passthru // {
131 inherit (base)
132 runtime
133 aspnetcore
134 ;
135 inherit (fallback.unwrapped)
136 pname
137 version
138 ;
139 };
140 });
141
142 withFallbackPackages = withBaseRuntimes.overrideAttrs (old: {
143 passthru =
144 old.passthru
145 // (
146 let
147 hostRid = pkgs.systemToDotnetRid base.stdenv.hostPlatform.system;
148 hasILCompiler = base.hasILCompiler || fallback.hasILCompiler;
149 packageName = "runtime.${hostRid}.Microsoft.DotNet.ILCompiler";
150 mergePackages =
151 a: b:
152 let
153 names = lib.genAttrs' a (p: lib.nameValuePair p.pname null);
154 in
155 a ++ lib.filter (p: !lib.hasAttr p.pname names) b;
156 packages = mergePackages base.packages fallback.packages;
157 targetPackages = lib.mapAttrs (
158 name: value: mergePackages value fallback.targetPackages.${name}
159 ) base.targetPackages;
160 in
161 {
162 inherit hasILCompiler packages targetPackages;
163 }
164 );
165 });
166 in
167 pkgs.callPackage ./wrapper.nix { } "sdk" withFallbackPackages;
168
169in
170pkgs
171// rec {
172 # use binary SDK here to avoid downgrading feature band
173 # combining sdk_8 results in a broken ilcompiler
174 sdk_8_0_1xx = if !pkgs.dotnet_8.vmr.meta.broken then pkgs.dotnet_8.sdk else pkgs.sdk_8_0_1xx-bin;
175 sdk_9_0_1xx = combineSdk pkgs.dotnet_9.sdk pkgs.sdk_9_0_1xx-bin;
176 sdk_10_0_1xx = combineSdk pkgs.dotnet_10.sdk pkgs.sdk_10_0_1xx-bin;
177 sdk_11_0_1xx = combineSdk pkgs.dotnet_11.sdk pkgs.sdk_11_0_1xx-bin;
178 # source-built SDK only exists for _1xx feature band
179 # https://github.com/dotnet/source-build/issues/3667
180 sdk_8_0_4xx = combineSdk sdk_8_0_1xx pkgs.sdk_8_0_4xx-bin;
181 sdk_9_0_3xx = combineSdk sdk_9_0_1xx pkgs.sdk_9_0_3xx-bin;
182 sdk_8_0 = sdk_8_0_4xx;
183 sdk_9_0 = sdk_9_0_3xx;
184 sdk_10_0 = sdk_10_0_1xx;
185 sdk_11_0 = sdk_11_0_1xx;
186 sdk_8_0-source = if !pkgs.dotnet_8.vmr.meta.broken then pkgs.dotnet_8.sdk else pkgs.sdk_8_0_1xx-bin;
187 sdk_9_0-source = if !pkgs.dotnet_9.vmr.meta.broken then pkgs.dotnet_9.sdk else pkgs.sdk_9_0_1xx-bin;
188 sdk_10_0-source =
189 if !pkgs.dotnet_10.vmr.meta.broken then pkgs.dotnet_10.sdk else pkgs.sdk_10_0_1xx-bin;
190 sdk_11_0-source =
191 if !pkgs.dotnet_11.vmr.meta.broken then pkgs.dotnet_11.sdk else pkgs.sdk_11_0_1xx-bin;
192 runtime_8_0 = sdk_8_0.runtime;
193 runtime_9_0 = sdk_9_0.runtime;
194 runtime_10_0 = sdk_10_0.runtime;
195 runtime_11_0 = sdk_11_0.runtime;
196 aspnetcore_8_0 = sdk_8_0.aspnetcore;
197 aspnetcore_9_0 = sdk_9_0.aspnetcore;
198 aspnetcore_10_0 = sdk_10_0.aspnetcore;
199 aspnetcore_11_0 = sdk_11_0.aspnetcore;
200}