···5151 echo " };"
5252}
53535454-sdk_packages () {
5454+generate_package_list() {
5555+ local version pkgs nuget_url
5656+ version="$1"
5757+ shift
5858+ pkgs=( "$@" )
5959+6060+ nuget_url="$(curl -f "https://api.nuget.org/v3/index.json" | jq --raw-output '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"')"
6161+6262+ for pkg in "${pkgs[@]}"; do
6363+ local url hash
6464+ url="${nuget_url}${pkg,,}/${version,,}/${pkg,,}.${version,,}.nupkg"
6565+ hash="$(nix-prefetch-url "$url")"
6666+ echo " (fetchNuGet { pname = \"${pkg}\"; version = \"${version}\"; sha256 = \"${hash}\"; })"
6767+ done
6868+}
6969+7070+aspnetcore_packages () {
5571 local version=$1
5672 # These packages are implicitly references by the build process,
5773 # based on the specific project configurations (RIDs, used features, etc.)
···89105 "Microsoft.AspNetCore.App.Runtime.win-arm64" \
90106 "Microsoft.AspNetCore.App.Runtime.win-x64" \
91107 "Microsoft.AspNetCore.App.Runtime.win-x86" \
108108+ )
109109+110110+ generate_package_list "$version" "${pkgs[@]}"
111111+}
112112+113113+sdk_packages () {
114114+ local version=$1
115115+ # These packages are implicitly references by the build process,
116116+ # based on the specific project configurations (RIDs, used features, etc.)
117117+ # They are always referenced with the same version as the SDK used for building.
118118+ # Since we lock nuget dependencies, when these packages are included in the generated
119119+ # lock files (deps.nix), every update of SDK required those lock files to be
120120+ # updated to reflect the new versions of these packages - otherwise, the build
121121+ # would fail due to missing dependencies.
122122+ #
123123+ # Moving them to a separate list stored alongside the SDK package definitions,
124124+ # and implictly including them along in buildDotnetModule allows us
125125+ # to make updating .NET SDK packages a lot easier - we now just update
126126+ # the versions of these packages in one place, and all packages that
127127+ # use buildDotnetModule continue building with the new .NET version without changes.
128128+ #
129129+ # Keep in mind that there is no canonical list of these implicitly
130130+ # referenced packages - this list was created based on looking into
131131+ # the deps.nix files of existing packages, and which dependencies required
132132+ # updating after a SDK version bump.
133133+ #
134134+ # Due to this, make sure to check if new SDK versions introduce any new packages.
135135+ # This should not happend in minor or bugfix updates, but probably happens
136136+ # with every new major .NET release.
137137+ local pkgs=( \
92138 "Microsoft.NETCore.App.Composite" \
93139 "Microsoft.NETCore.App.Host.linux-arm" \
94140 "Microsoft.NETCore.App.Host.linux-arm64" \
···109155 "Microsoft.NETCore.App.Runtime.linux-musl-arm64" \
110156 "Microsoft.NETCore.App.Runtime.linux-musl-x64" \
111157 "Microsoft.NETCore.App.Runtime.linux-x64" \
158158+ "Microsoft.NETCore.App.Runtime.Mono.linux-arm" \
159159+ "Microsoft.NETCore.App.Runtime.Mono.linux-arm64" \
160160+ "Microsoft.NETCore.App.Runtime.Mono.linux-musl-x64" \
161161+ "Microsoft.NETCore.App.Runtime.Mono.linux-x64" \
162162+ "Microsoft.NETCore.App.Runtime.Mono.osx-arm64" \
163163+ "Microsoft.NETCore.App.Runtime.Mono.osx-x64" \
164164+ "Microsoft.NETCore.App.Runtime.Mono.win-x64" \
165165+ "Microsoft.NETCore.App.Runtime.Mono.win-x86" \
112166 "Microsoft.NETCore.App.Runtime.osx-arm64" \
113167 "Microsoft.NETCore.App.Runtime.osx-x64" \
114168 "Microsoft.NETCore.App.Runtime.win-arm" \
···169223 "runtime.win-x86.Microsoft.NETCore.DotNetHostResolver" \
170224 )
171225172172- local nuget_url="$(curl -f "https://api.nuget.org/v3/index.json" | jq --raw-output '.resources[] | select(."@type" == "PackageBaseAddress/3.0.0")."@id"')"
226226+ # Packages that only apply to .NET 7 and up
227227+ if [[ ! ( "$version" =~ ^[1-6]\. ) ]]; then
228228+ # ILCompiler requires nixpkgs#181373 to be fixed to work properly
229229+ pkgs+=( \
230230+ "runtime.linux-arm64.Microsoft.DotNet.ILCompiler" \
231231+ "runtime.linux-musl-arm64.Microsoft.DotNet.ILCompiler" \
232232+ "runtime.linux-musl-x64.Microsoft.DotNet.ILCompiler" \
233233+ "runtime.linux-x64.Microsoft.DotNet.ILCompiler" \
234234+ "runtime.osx-x64.Microsoft.DotNet.ILCompiler" \
235235+ "runtime.win-arm64.Microsoft.DotNet.ILCompiler" \
236236+ "runtime.win-x64.Microsoft.DotNet.ILCompiler" \
237237+ )
238238+ fi
173239174174- for pkg in "${pkgs[@]}"; do
175175- local url hash
176176- url="${nuget_url}${pkg,,}/${version,,}/${pkg,,}.${version,,}.nupkg"
177177- hash="$(nix-prefetch-url "$url")"
178178- echo " (fetchNuGet { pname = \"${pkg}\"; version = \"${version}\"; sha256 = \"${hash}\"; })"
179179- done
240240+ generate_package_list "$version" "${pkgs[@]}"
180241}
181242182243main () {
···244305 version = \"${sdk_version}\";
245306 $(platform_sources "$sdk_files")
246307 packages = { fetchNuGet }: [
308308+$(aspnetcore_packages "${aspnetcore_version}")
247309$(sdk_packages "${runtime_version}")
248310 ];
249311 };