nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at fix-function-merge 93 lines 3.5 kB view raw
1{ lib 2, localSystem, crossSystem, config, overlays, crossOverlays ? [] 3}: 4 5let 6 bootStages = import ../. { 7 inherit lib localSystem overlays; 8 9 crossSystem = localSystem; 10 crossOverlays = []; 11 12 # Ignore custom stdenvs when cross compiling for compatibility 13 # Use replaceCrossStdenv instead. 14 config = builtins.removeAttrs config [ "replaceStdenv" ]; 15 }; 16 17in lib.init bootStages ++ [ 18 19 # Regular native packages 20 (somePrevStage: lib.last bootStages somePrevStage // { 21 # It's OK to change the built-time dependencies 22 allowCustomOverrides = true; 23 }) 24 25 # Build tool Packages 26 (vanillaPackages: { 27 inherit config overlays; 28 selfBuild = false; 29 stdenv = 30 assert vanillaPackages.stdenv.buildPlatform == localSystem; 31 assert vanillaPackages.stdenv.hostPlatform == localSystem; 32 assert vanillaPackages.stdenv.targetPlatform == localSystem; 33 vanillaPackages.stdenv.override { targetPlatform = crossSystem; }; 34 # It's OK to change the built-time dependencies 35 allowCustomOverrides = true; 36 }) 37 38 # Run Packages 39 (buildPackages: let 40 adaptStdenv = 41 if crossSystem.isStatic 42 then buildPackages.stdenvAdapters.makeStatic 43 else lib.id; 44 in { 45 inherit config; 46 overlays = overlays ++ crossOverlays; 47 selfBuild = false; 48 stdenv = let 49 baseStdenv = adaptStdenv (buildPackages.stdenv.override (old: rec { 50 buildPlatform = localSystem; 51 hostPlatform = crossSystem; 52 targetPlatform = crossSystem; 53 54 # Prior overrides are surely not valid as packages built with this run on 55 # a different platform, and so are disabled. 56 overrides = _: _: {}; 57 extraBuildInputs = [ ] # Old ones run on wrong platform 58 ++ lib.optionals hostPlatform.isDarwin [ buildPackages.targetPackages.darwin.apple_sdk.frameworks.CoreFoundation ] 59 ; 60 allowedRequisites = null; 61 62 hasCC = !targetPlatform.isGhcjs; 63 64 cc = if crossSystem.useiOSPrebuilt or false 65 then buildPackages.darwin.iosSdkPkgs.clang 66 else if crossSystem.useAndroidPrebuilt or false 67 then buildPackages."androidndkPkgs_${crossSystem.ndkVer}".clang 68 else if targetPlatform.isGhcjs 69 # Need to use `throw` so tryEval for splicing works, ugh. Using 70 # `null` or skipping the attribute would cause an eval failure 71 # `tryEval` wouldn't catch, wrecking accessing previous stages 72 # when there is a C compiler and everything should be fine. 73 then throw "no C compiler provided for this platform" 74 else if crossSystem.isDarwin 75 then buildPackages.llvmPackages.libcxxClang 76 else if crossSystem.useLLVM or false 77 then buildPackages.llvmPackages.clang 78 else buildPackages.gcc; 79 80 extraNativeBuildInputs = old.extraNativeBuildInputs 81 ++ lib.optionals 82 (hostPlatform.isLinux && !buildPlatform.isLinux) 83 [ buildPackages.patchelf ] 84 ++ lib.optional 85 (let f = p: !p.isx86 || builtins.elem p.libc [ "musl" "wasilibc" "relibc" ] || p.isiOS || p.isGenode; 86 in f hostPlatform && !(f buildPlatform) ) 87 buildPackages.updateAutotoolsGnuConfigScriptsHook 88 ; 89 })); 90 in if config ? replaceCrossStdenv then config.replaceCrossStdenv { inherit buildPackages baseStdenv; } else baseStdenv; 91 }) 92 93]