Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at flake-libs 188 lines 7.2 kB view raw
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 recurseIntoAttrs, 12 generateSplicesForMkScope, 13 makeScopeWithSplicing', 14 writeScriptBin, 15}: 16 17let 18 pkgs = makeScopeWithSplicing' { 19 otherSplices = generateSplicesForMkScope "dotnetCorePackages"; 20 f = ( 21 self: 22 let 23 callPackage = self.callPackage; 24 25 fetchNupkg = callPackage ../../../build-support/dotnet/fetch-nupkg { }; 26 27 buildDotnet = attrs: callPackage (import ./build-dotnet.nix attrs) { }; 28 buildDotnetSdk = 29 version: 30 import version { 31 inherit fetchNupkg; 32 buildAspNetCore = attrs: buildDotnet (attrs // { type = "aspnetcore"; }); 33 buildNetRuntime = attrs: buildDotnet (attrs // { type = "runtime"; }); 34 buildNetSdk = attrs: buildDotnet (attrs // { type = "sdk"; }); 35 }; 36 37 ## Files in versions/ are generated automatically by update.sh ## 38 dotnet-bin = lib.mergeAttrsList ( 39 map buildDotnetSdk [ 40 ./versions/6.0.nix 41 ./versions/7.0.nix 42 ./versions/8.0.nix 43 ./versions/9.0.nix 44 ./versions/10.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 = recurseIntoAttrs (callPackage ./8 { }); 96 dotnet_9 = recurseIntoAttrs (callPackage ./9 { }); 97 dotnet_10 = recurseIntoAttrs (callPackage ./10 { }); 98 } 99 ); 100 }; 101 102 # combine an SDK with the runtime/packages from a base SDK 103 combineSdk = 104 base: overlay: 105 if (overlay.runtime.version != base.runtime.version) then 106 throw "combineSdk: unable to combine ${overlay.name} with ${base.name} because runtime versions don't match (${overlay.runtime.version} != ${base.runtime.version})" 107 else 108 pkgs.callPackage ./wrapper.nix { } "sdk" ( 109 (pkgs.combinePackages [ 110 base.runtime 111 base.aspnetcore 112 (overlay.overrideAttrs (old: { 113 passthru = old.passthru // { 114 inherit (base) 115 packages 116 targetPackages 117 ; 118 }; 119 })) 120 ]).unwrapped.overrideAttrs 121 (old: { 122 name = overlay.unwrapped.name; 123 # resolve symlinks so DOTNET_ROOT is self-contained 124 postBuild = 125 '' 126 mv "$out"/share/dotnet{,~} 127 cp -Lr "$out"/share/dotnet{~,} 128 rm -r "$out"/share/dotnet~ 129 '' 130 + old.postBuild; 131 passthru = 132 old.passthru 133 // ( 134 let 135 # if only overlay has a working ILCompiler, use it 136 hostRid = pkgs.systemToDotnetRid base.stdenv.hostPlatform.system; 137 hasILCompiler = base.hasILCompiler || overlay.hasILCompiler; 138 packageName = "runtime.${hostRid}.Microsoft.DotNet.ILCompiler"; 139 packages = 140 if !base.hasILCompiler && overlay.hasILCompiler then 141 lib.filter (x: x.pname != packageName) base.packages 142 ++ lib.filter (x: x.pname == packageName) overlay.packages 143 else 144 base.packages; 145 in 146 { 147 inherit hasILCompiler packages; 148 inherit (base) 149 targetPackages 150 runtime 151 aspnetcore 152 ; 153 inherit (overlay.unwrapped) 154 pname 155 version 156 ; 157 } 158 ); 159 }) 160 ); 161 162in 163pkgs 164// rec { 165 # use binary SDK here to avoid downgrading feature band 166 sdk_8_0_1xx = if !pkgs.dotnet_8.vmr.meta.broken then pkgs.dotnet_8.sdk else pkgs.sdk_8_0_1xx-bin; 167 sdk_9_0_1xx = if !pkgs.dotnet_9.vmr.meta.broken then pkgs.dotnet_9.sdk else pkgs.sdk_9_0_1xx-bin; 168 sdk_10_0_1xx = 169 if !pkgs.dotnet_10.vmr.meta.broken then pkgs.dotnet_10.sdk else pkgs.sdk_10_0_1xx-bin; 170 # source-built SDK only exists for _1xx feature band 171 # https://github.com/dotnet/source-build/issues/3667 172 sdk_8_0_3xx = combineSdk sdk_8_0_1xx pkgs.sdk_8_0_3xx-bin; 173 sdk_8_0_4xx = combineSdk sdk_8_0_1xx pkgs.sdk_8_0_4xx-bin; 174 sdk_9_0_2xx = combineSdk sdk_9_0_1xx pkgs.sdk_9_0_2xx-bin; 175 sdk_9_0_3xx = combineSdk sdk_9_0_1xx pkgs.sdk_9_0_3xx-bin; 176 sdk_8_0 = sdk_8_0_4xx; 177 sdk_9_0 = sdk_9_0_2xx; 178 sdk_10_0 = sdk_10_0_1xx; 179 sdk_8_0-source = sdk_8_0_1xx; 180 sdk_9_0-source = sdk_9_0_1xx; 181 sdk_10_0-source = sdk_10_0_1xx; 182 runtime_8_0 = sdk_8_0.runtime; 183 runtime_9_0 = sdk_9_0.runtime; 184 runtime_10_0 = sdk_10_0.runtime; 185 aspnetcore_8_0 = sdk_8_0.aspnetcore; 186 aspnetcore_9_0 = sdk_9_0.aspnetcore; 187 aspnetcore_10_0 = sdk_10_0.aspnetcore; 188}