@@ -61,6 +61,35 @@ let
6161 inherit system bootStdenv noSysDirs config crossSystem platform lib;
6262 };
6363
64+ stdenvAdapters = self: super:
65+ let res = import ../stdenv/adapters.nix self; in res // {
66+ stdenvAdapters = res;
67+ };
68+
69+ trivialBuilders = self: super:
70+ (import ../build-support/trivial-builders.nix {
71+ inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
72+ });
73+
74+ stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs;
75+
76+ allPackages = self: super:
77+ let res = import ./all-packages.nix topLevelArguments res self;
78+ in res;
79+
80+ aliases = self: super: import ./aliases.nix super;
81+
82+ # stdenvOverrides is used to avoid circular dependencies for building
83+ # the standard build environment. This mechanism uses the override
84+ # mechanism to implement some staged compilation of the stdenv.
85+ #
86+ # We don't want stdenv overrides in the case of cross-building, or
87+ # otherwise the basic overridden packages will not be built with the
88+ # crossStdenv adapter.
89+ stdenvOverrides = self: super:
90+ lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides)
91+ (super.stdenv.overrides super);
92+
6493 # Allow packages to be overridden globally via the `packageOverrides'
6594 # configuration option, which must be a function that takes `pkgs'
6695 # as an argument and returns a set of new or overridden packages.
@@ -68,54 +97,34 @@ let
6897 # (un-overridden) set of packages, allowing packageOverrides
6998 # attributes to refer to the original attributes (e.g. "foo =
7099 # ... pkgs.foo ...").
71− pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {}));
72−
73− # Return the complete set of packages, after applying the overrides
74− # returned by the `overrider' function (see above). Warning: this
75− # function is very expensive!
76− pkgsWithOverrides = overrider:
77− let
78− stdenvAdapters = self: super:
79− let res = import ../stdenv/adapters.nix self; in res // {
80− stdenvAdapters = res;
81− };
82−
83− trivialBuilders = self: super:
84− (import ../build-support/trivial-builders.nix {
85− inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
86− });
87−
88− stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs;
89−
90− allPackagesArgs = topLevelArguments // { inherit pkgsWithOverrides; };
91− allPackages = self: super:
92− let res = import ./all-packages.nix allPackagesArgs res self;
93− in res;
94−
95− aliases = self: super: import ./aliases.nix super;
96−
97− # stdenvOverrides is used to avoid circular dependencies for building
98− # the standard build environment. This mechanism uses the override
99− # mechanism to implement some staged compilation of the stdenv.
100− #
101− # We don't want stdenv overrides in the case of cross-building, or
102− # otherwise the basic overridden packages will not be built with the
103− # crossStdenv adapter.
104− stdenvOverrides = self: super:
105− lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides)
106− (super.stdenv.overrides super);
107−
108− customOverrides = self: super:
109− lib.optionalAttrs (bootStdenv == null) (overrider self super);
110− in
111− lib.fix' (
112− lib.extends customOverrides (
113− lib.extends stdenvOverrides (
114− lib.extends aliases (
115− lib.extends allPackages (
116− lib.extends stdenvDefault (
117− lib.extends trivialBuilders (
118− lib.extends stdenvAdapters (
119− self: {}))))))));
120−in
121− pkgs
100+ configOverrides = self: super:
101+ lib.optionalAttrs (bootStdenv == null)
102+ ((config.packageOverrides or (super: {})) super);
103+
104+ # The complete chain of package set builders, applied from bottom to top
105+ toFix = lib.fold lib.extends (self: {}) [
106+ configOverrides
107+ stdenvOverrides
108+ aliases
109+ allPackages
110+ stdenvDefault
111+ trivialBuilders
112+ stdenvAdapters
113+ ];
114+
115+ # Use `overridePackages` to easily override this package set.
116+ # Warning: this function is very expensive and must not be used
117+ # from within the nixpkgs repository.
118+ #
119+ # Example:
120+ # pkgs.overridePackages (self: super: {
121+ # foo = super.foo.override { ... };
122+ # }
123+ #
124+ # The result is `pkgs' where all the derivations depending on `foo'
125+ # will use the new version.
126+
127+ # Return the complete set of packages. Warning: this function is very
128+ # expensive!
129+ pkgs = lib.makeExtensibleWithCustomName "overridePackages" toFix;
130+in pkgs