summary refs log tree commit diff
path: root/pkgs/stdenv/cross/default.nix
blob: e684c14da4a54995ce6cc721318b11d452b01ea2 (plain) (blame)
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
{ lib
, system, platform, crossSystem, config, overlays
}:

let
  bootStages = import ../. {
    inherit lib system platform overlays;
    crossSystem = null;
    # Ignore custom stdenvs when cross compiling for compatability
    config = builtins.removeAttrs config [ "replaceStdenv" ];
  };

in bootStages ++ [

  # Build Packages
  (vanillaPackages: {
    inherit system platform crossSystem config overlays;
    # Should be false, but we're trying to preserve hashes for now
    selfBuild = true;
    # It's OK to change the built-time dependencies
    allowCustomOverrides = true;
    stdenv = vanillaPackages.stdenv // {
      # Needed elsewhere as a hacky way to pass the target
      cross = crossSystem;
      overrides = _: _: {};
    };
  })

  # Run Packages
  (buildPackages: {
    inherit system platform crossSystem config overlays;
    selfBuild = false;
    stdenv = if crossSystem.useiOSCross or false
      then let
          inherit (buildPackages.darwin.ios-cross {
              prefix = crossSystem.config;
              inherit (crossSystem) arch;
              simulator = crossSystem.isiPhoneSimulator or false; })
            cc binutils;
        in buildPackages.makeStdenvCross
          buildPackages.stdenv crossSystem
          binutils cc
      else buildPackages.makeStdenvCross
        buildPackages.stdenv crossSystem
        buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
  })

]