nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 191 lines 7.4 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 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 ] 45 ); 46 47 runtimeIdentifierMap = { 48 "x86_64-linux" = "linux-x64"; 49 "aarch64-linux" = "linux-arm64"; 50 "x86_64-darwin" = "osx-x64"; 51 "aarch64-darwin" = "osx-arm64"; 52 "x86_64-windows" = "win-x64"; 53 "i686-windows" = "win-x86"; 54 }; 55 56 in 57 lib.optionalAttrs config.allowAliases ( 58 { 59 # EOL 60 sdk_2_1 = throw "Dotnet SDK 2.1 is EOL, please use 8.0 (LTS) or 9.0 (Current)"; 61 sdk_2_2 = throw "Dotnet SDK 2.2 is EOL, please use 8.0 (LTS) or 9.0 (Current)"; 62 sdk_3_0 = throw "Dotnet SDK 3.0 is EOL, please use 8.0 (LTS) or 9.0 (Current)"; 63 sdk_3_1 = throw "Dotnet SDK 3.1 is EOL, please use 8.0 (LTS) or 9.0 (Current)"; 64 sdk_5_0 = throw "Dotnet SDK 5.0 is EOL, please use 8.0 (LTS) or 9.0 (Current)"; 65 } 66 // dotnet-bin 67 ) 68 // lib.mapAttrs' (k: v: lib.nameValuePair "${k}-bin" v) dotnet-bin 69 // { 70 inherit callPackage fetchNupkg buildDotnetSdk; 71 72 generate-dotnet-sdk = writeScriptBin "generate-dotnet-sdk" ( 73 # Don't include current nixpkgs in the exposed version. We want to make the script runnable without nixpkgs repo. 74 builtins.replaceStrings [ " -I nixpkgs=./." ] [ "" ] (builtins.readFile ./update.sh) 75 ); 76 77 # Convert a "stdenv.hostPlatform.system" to a dotnet RID 78 systemToDotnetRid = 79 system: runtimeIdentifierMap.${system} or (throw "unsupported platform ${system}"); 80 81 combinePackages = attrs: callPackage (import ./combine-packages.nix attrs) { }; 82 83 patchNupkgs = callPackage ./patch-nupkgs.nix { }; 84 nugetPackageHook = callPackage ./nuget-package-hook.nix { }; 85 autoPatchcilHook = callPackage ../../../build-support/dotnet/auto-patchcil-hook { }; 86 87 buildDotnetModule = callPackage ../../../build-support/dotnet/build-dotnet-module { }; 88 buildDotnetGlobalTool = callPackage ../../../build-support/dotnet/build-dotnet-global-tool { }; 89 90 mkNugetSource = callPackage ../../../build-support/dotnet/make-nuget-source { }; 91 mkNugetDeps = callPackage ../../../build-support/dotnet/make-nuget-deps { }; 92 addNuGetDeps = callPackage ../../../build-support/dotnet/add-nuget-deps { }; 93 94 dotnet_8 = lib.recurseIntoAttrs (callPackage ./8 { }); 95 dotnet_9 = lib.recurseIntoAttrs (callPackage ./9 { }); 96 dotnet_10 = lib.recurseIntoAttrs (callPackage ./10 { }); 97 } 98 ); 99 }; 100 101 # combine an SDK with the runtime/packages from a base SDK 102 combineSdk = 103 base: fallback: 104 if (fallback.runtime.version != base.runtime.version) then 105 throw "combineSdk: unable to combine ${fallback.name} with ${base.name} because runtime versions don't match (${fallback.runtime.version} != ${base.runtime.version})" 106 else if base.meta.broken then 107 fallback 108 else 109 let 110 withBaseRuntimes = 111 if fallback.version == base.version then 112 base.unwrapped 113 else 114 (pkgs.combinePackages [ 115 base.runtime 116 base.aspnetcore 117 fallback 118 ]).unwrapped.overrideAttrs 119 (old: { 120 name = fallback.unwrapped.name; 121 # resolve symlinks so DOTNET_ROOT is self-contained 122 postBuild = '' 123 mv "$out"/share/dotnet{,~} 124 cp -Lr "$out"/share/dotnet{~,} 125 rm -r "$out"/share/dotnet~ 126 '' 127 + old.postBuild; 128 passthru = old.passthru // { 129 inherit (base) 130 runtime 131 aspnetcore 132 ; 133 inherit (fallback.unwrapped) 134 pname 135 version 136 ; 137 }; 138 }); 139 140 withFallbackPackages = withBaseRuntimes.overrideAttrs (old: { 141 passthru = 142 old.passthru 143 // ( 144 let 145 hostRid = pkgs.systemToDotnetRid base.stdenv.hostPlatform.system; 146 hasILCompiler = base.hasILCompiler || fallback.hasILCompiler; 147 packageName = "runtime.${hostRid}.Microsoft.DotNet.ILCompiler"; 148 mergePackages = 149 a: b: 150 let 151 names = lib.genAttrs' a (p: lib.nameValuePair p.pname null); 152 in 153 a ++ lib.filter (p: !lib.hasAttr p.pname names) b; 154 packages = mergePackages base.packages fallback.packages; 155 targetPackages = lib.mapAttrs ( 156 name: value: mergePackages value fallback.targetPackages.${name} 157 ) base.targetPackages; 158 in 159 { 160 inherit hasILCompiler packages targetPackages; 161 } 162 ); 163 }); 164 in 165 pkgs.callPackage ./wrapper.nix { } "sdk" withFallbackPackages; 166 167in 168pkgs 169// rec { 170 # use binary SDK here to avoid downgrading feature band 171 sdk_8_0_1xx = combineSdk pkgs.dotnet_8.sdk pkgs.sdk_8_0_1xx-bin; 172 sdk_9_0_1xx = combineSdk pkgs.dotnet_9.sdk pkgs.sdk_9_0_1xx-bin; 173 sdk_10_0_1xx = combineSdk pkgs.dotnet_10.sdk pkgs.sdk_10_0_1xx-bin; 174 # source-built SDK only exists for _1xx feature band 175 # https://github.com/dotnet/source-build/issues/3667 176 sdk_8_0_4xx = combineSdk sdk_8_0_1xx pkgs.sdk_8_0_4xx-bin; 177 sdk_9_0_3xx = combineSdk sdk_9_0_1xx pkgs.sdk_9_0_3xx-bin; 178 sdk_8_0 = sdk_8_0_4xx; 179 sdk_9_0 = sdk_9_0_3xx; 180 sdk_10_0 = sdk_10_0_1xx; 181 sdk_8_0-source = if !pkgs.dotnet_8.vmr.meta.broken then pkgs.dotnet_8.sdk else pkgs.sdk_8_0_1xx-bin; 182 sdk_9_0-source = if !pkgs.dotnet_9.vmr.meta.broken then pkgs.dotnet_9.sdk else pkgs.sdk_9_0_1xx-bin; 183 sdk_10_0-source = 184 if !pkgs.dotnet_10.vmr.meta.broken then pkgs.dotnet_10.sdk else pkgs.sdk_10_0_1xx-bin; 185 runtime_8_0 = sdk_8_0.runtime; 186 runtime_9_0 = sdk_9_0.runtime; 187 runtime_10_0 = sdk_10_0.runtime; 188 aspnetcore_8_0 = sdk_8_0.aspnetcore; 189 aspnetcore_9_0 = sdk_9_0.aspnetcore; 190 aspnetcore_10_0 = sdk_10_0.aspnetcore; 191}