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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
|
{
config,
stdenvNoCC,
callPackage,
lib,
fetchurl,
channel,
featureBand ? "1xx",
dir ? ../. + ("/" + channel),
releaseManifestFile ? dir + "/release.json",
releaseInfoFile ? dir + "/release-info.json",
bootstrapSdkFile ? dir + "/bootstrap-sdk.nix",
bootstrapSdk ? null,
depsFile ? dir + "/deps.json",
pkgsBuildHost,
buildDotnetSdk,
withBinary ? true,
combinePackages,
systemToDotnetRid,
binary,
}@attrs:
assert bootstrapSdk != null || bootstrapSdkFile != null;
let
suffix =
let
parts = lib.splitVersion channel;
major = lib.elemAt parts 0;
sdk = lib.concatStringsSep "_" (parts ++ [ featureBand ]);
in
{
source = if featureBand == "1xx" then major else sdk;
channel = lib.concatStringsSep "_" (lib.take 2 parts);
inherit major sdk;
};
releaseInfo = (lib.importJSON releaseInfoFile);
inherit (releaseInfo)
tarballHash
artifactsUrl
artifactsHash
;
artifacts = stdenvNoCC.mkDerivation {
name = lib.nameFromURL artifactsUrl ".tar.gz";
src = fetchurl {
url = artifactsUrl;
hash = artifactsHash;
};
sourceRoot = ".";
installPhase = ''
mkdir -p $out
cp -r * $out/
'';
};
vmr =
if bootstrapSdk != null then
callPackage ./vmr.nix {
inherit
releaseManifestFile
tarballHash
;
inherit bootstrapSdk;
hasRuntime = false;
}
else
callPackage ./stage1.nix {
inherit
releaseManifestFile
tarballHash
depsFile
;
bootstrapSdk = (buildDotnetSdk bootstrapSdkFile).sdk.overrideAttrs (old: {
passthru = old.passthru or { } // {
inherit artifacts;
};
});
};
fallbackSdk = binary.${"sdk_${suffix.sdk}"};
fallbackTargetPackages = fallbackSdk.targetPackages;
vmrPackages =
let
pkgs = callPackage ./packages.nix {
inherit vmr fallbackTargetPackages;
};
in
lib.recurseIntoAttrs pkgs;
source =
vmrPackages
// lib.optionalAttrs vmr.meta.broken rec {
sdk = fallbackSdk;
inherit (sdk) runtime aspnetcore;
};
# combine an SDK with the runtime/packages from a base SDK
combineSdk =
base: fallback:
if (fallback.runtime.version != base.runtime.version) then
throw "combineSdk: unable to combine ${fallback.name} with ${base.name} because runtime versions don't match (${fallback.runtime.version} != ${base.runtime.version})"
else if base.meta.broken then
fallback
else
let
withBaseRuntimes =
if fallback.version == base.version then
base.unwrapped
else
(combinePackages [
base.runtime
base.aspnetcore
fallback
]).unwrapped.overrideAttrs
(old: {
name = fallback.unwrapped.name;
# resolve symlinks so DOTNET_ROOT is self-contained
postBuild = ''
mv "$out"/share/dotnet{,~}
cp -Lr "$out"/share/dotnet{~,}
rm -r "$out"/share/dotnet~
''
+ old.postBuild;
passthru = old.passthru // {
inherit (base)
runtime
aspnetcore
;
inherit (fallback.unwrapped)
pname
version
hasILCompiler
;
};
});
withFallbackPackages = withBaseRuntimes.overrideAttrs (old: {
passthru =
old.passthru
// (
let
hostRid = systemToDotnetRid base.stdenv.hostPlatform.system;
hasILCompiler = base.hasILCompiler || withBaseRuntimes.hasILCompiler;
packageName = "runtime.${hostRid}.Microsoft.DotNet.ILCompiler";
mergePackages =
a: b:
let
names = lib.genAttrs' a (p: lib.nameValuePair p.pname null);
in
a ++ lib.filter (p: !lib.hasAttr p.pname names) b;
packages = mergePackages base.packages fallback.packages;
targetPackages = lib.mapAttrs (
name: value: mergePackages value fallback.targetPackages.${name}
) base.targetPackages;
in
{
inherit hasILCompiler packages targetPackages;
}
);
});
in
callPackage ../wrapper.nix { } "sdk" withFallbackPackages;
in
{
"dotnet_${suffix.source}" = vmrPackages;
}
// (
let
combined = lib.mapAttrs (s: v: combineSdk source.sdk v) (
if withBinary then
lib.filterAttrs (n: _: lib.substring 0 4 n == "sdk_") binary
else
{
"sdk_${suffix.sdk}" = binary.${"sdk_${suffix.sdk}"};
}
//
lib.optionalAttrs (lib.versionAtLeast source.sdk.version binary.${"sdk_${suffix.channel}"}.version)
{
"sdk_${suffix.channel}" = binary.${"sdk_${suffix.channel}"};
}
);
in
combined
// {
"sdk_${suffix.channel}-source" = source.sdk;
"runtime_${suffix.channel}" = source.runtime;
"aspnetcore_${suffix.channel}" = source.aspnetcore;
}
)
// lib.optionalAttrs withBinary (
lib.mergeAttrsList (
map
(
featureBand:
callPackage ./default.nix (
attrs
// {
inherit featureBand;
dir = dir + "/${featureBand}";
withBinary = false;
bootstrapSdk = vmrPackages.sdk;
}
)
)
(
lib.filter (x: x != "1xx") (
map (x: lib.elemAt x 2) (
lib.filter (x: x != null && lib.versionAtLeast (lib.elemAt x 0) "10") (
map (lib.match "sdk_(.*)_(.*)_(.*)") (lib.attrNames binary)
)
)
)
)
)
)
|