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