summaryrefslogtreecommitdiffstats
path: root/pkgs/stdenv/darwin/make-bootstrap-tools.nix
blob: 49ea90cda7bd3ac1d3b181237869750ac20dfecd (plain)
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
{
  pkgspath ? ../../..,
  test-pkgspath ? pkgspath,
  localSystem ? {
    system = builtins.currentSystem;
  },
  crossSystem ? null,
  bootstrapFiles ? null,
}:

let
  cross = if crossSystem != null then { inherit crossSystem; } else { };

  custom-bootstrap =
    if bootstrapFiles != null then
      {
        stdenvStages =
          args:
          let
            args' = args // {
              bootstrapFiles = bootstrapFiles;
            };
          in
          (import "${pkgspath}/pkgs/stdenv/darwin" args');
      }
    else
      { };

  pkgs = import pkgspath ({ inherit localSystem; } // cross // custom-bootstrap);

  build = pkgs.callPackage ./stdenv-bootstrap-tools.nix { };

  bootstrapTools = pkgs.callPackage ./bootstrap-tools.nix {
    inherit (build.bootstrapFiles) bootstrapTools unpack;
  };

  test = pkgs.callPackage ./test-bootstrap-tools.nix { inherit bootstrapTools; };

  # The ultimate test: bootstrap a whole stdenv from the tools specified above and get a package set out of it
  # eg: nix-build -A freshBootstrapTools.test-pkgs.stdenv
  test-pkgs = import test-pkgspath {
    # if the bootstrap tools are for another platform, we should be testing
    # that platform.
    localSystem = if crossSystem != null then crossSystem else localSystem;

    stdenvStages =
      args:
      let
        args' = args // {
          inherit (build) bootstrapFiles;
        };
      in
      (import (test-pkgspath + "/pkgs/stdenv/darwin") args');
  };
in
{
  inherit
    build
    bootstrapTools
    test
    test-pkgs
    ;

  inherit (build) bootstrapFiles;
}