summary refs log tree commit diff
path: root/pkgs/top-level/stdenv.nix
blob: f9ba5e7516ef8b51e1ccc372d085ac656fe39dc1 (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
{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, pkgs }:

rec {
  allStdenvs = import ../stdenv {
    inherit system platform config lib;
    # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
    allPackages = args: nixpkgsFun (args // { crossSystem = null; });
  };

  defaultStdenv = allStdenvs.stdenv // { inherit platform; };

  stdenv =
    if bootStdenv != null then (bootStdenv // {inherit platform;}) else
      if crossSystem != null then
        pkgs.stdenvCross
      else
        let
            changer = config.replaceStdenv or null;
        in if changer != null then
          changer {
            # We import again all-packages to avoid recursivities.
            pkgs = nixpkgsFun {
              # We remove packageOverrides to avoid recursivities
              config = removeAttrs config [ "replaceStdenv" ];
            };
          }
      else
        defaultStdenv;
}