summary refs log tree commit diff
path: root/pkgs/stdenv/cross/default.nix
blob: e48124f1c4dbc0fd1c924e0835a9de65f167fd8e (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
{ system, allPackages, platform, crossSystem, config, ... } @ args:

rec {
  argClobber = {
    crossSystem = null;
    # Ignore custom stdenvs when cross compiling for compatability
    config = builtins.removeAttrs config [ "replaceStdenv" ];
  };
  vanillaStdenv = (import ../. (args // argClobber // {
    allPackages = args: allPackages (argClobber // args);
  })) // {
    # Needed elsewhere as a hacky way to pass the target
    cross = crossSystem;
  };

  # For now, this is just used to build the native stdenv. Eventually, it should
  # be used to build compilers and other such tools targeting the cross
  # platform. Then, `forceNativeDrv` can be removed.
  buildPackages = allPackages {
    inherit system platform crossSystem config;
    # It's OK to change the built-time dependencies
    allowCustomOverrides = true;
    bootStdenv = vanillaStdenv;
  };

  stdenvCross = buildPackages.makeStdenvCross
    buildPackages.stdenv crossSystem
    buildPackages.binutilsCross buildPackages.gccCrossStageFinal;

  stdenvCrossiOS = 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;
}