diff options
author | John Ericson <jericson@galois.com> | 2016-10-12 15:14:49 -0400 |
---|---|---|
committer | John Ericson <jericson@galois.com> | 2016-10-13 11:14:11 -0400 |
commit | e4cd45a30c92a19a240df835cdaf6da5f76ea9fc (patch) | |
tree | fc234aeb6b3b5714be3c6db9e1c0607496d258d1 /pkgs/top-level/default.nix | |
parent | da36847d925058fd86f027b64cc712c57be11ad8 (diff) | |
download | nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.tar nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.tar.gz nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.tar.bz2 nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.tar.lz nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.tar.xz nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.tar.zst nixpkgs-e4cd45a30c92a19a240df835cdaf6da5f76ea9fc.zip |
top-level: Make `overridePackages` extend rather than replace existing overrides
Diffstat (limited to 'pkgs/top-level/default.nix')
-rw-r--r-- | pkgs/top-level/default.nix | 111 |
1 files changed, 60 insertions, 51 deletions
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix index 2eb7fb34b4d..d0dc231650c 100644 --- a/pkgs/top-level/default.nix +++ b/pkgs/top-level/default.nix @@ -61,6 +61,35 @@ let inherit system bootStdenv noSysDirs config crossSystem platform lib; }; + stdenvAdapters = self: super: + let res = import ../stdenv/adapters.nix self; in res // { + stdenvAdapters = res; + }; + + trivialBuilders = self: super: + (import ../build-support/trivial-builders.nix { + inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; + }); + + stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs; + + allPackages = self: super: + let res = import ./all-packages.nix topLevelArguments res self; + in res; + + aliases = self: super: import ./aliases.nix super; + + # stdenvOverrides is used to avoid circular dependencies for building + # the standard build environment. This mechanism uses the override + # mechanism to implement some staged compilation of the stdenv. + # + # We don't want stdenv overrides in the case of cross-building, or + # otherwise the basic overridden packages will not be built with the + # crossStdenv adapter. + stdenvOverrides = self: super: + lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides) + (super.stdenv.overrides super); + # Allow packages to be overridden globally via the `packageOverrides' # configuration option, which must be a function that takes `pkgs' # as an argument and returns a set of new or overridden packages. @@ -68,54 +97,34 @@ let # (un-overridden) set of packages, allowing packageOverrides # attributes to refer to the original attributes (e.g. "foo = # ... pkgs.foo ..."). - pkgs = pkgsWithOverrides (self: config.packageOverrides or (super: {})); - - # Return the complete set of packages, after applying the overrides - # returned by the `overrider' function (see above). Warning: this - # function is very expensive! - pkgsWithOverrides = overrider: - let - stdenvAdapters = self: super: - let res = import ../stdenv/adapters.nix self; in res // { - stdenvAdapters = res; - }; - - trivialBuilders = self: super: - (import ../build-support/trivial-builders.nix { - inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir; - }); - - stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs; - - allPackagesArgs = topLevelArguments // { inherit pkgsWithOverrides; }; - allPackages = self: super: - let res = import ./all-packages.nix allPackagesArgs res self; - in res; - - aliases = self: super: import ./aliases.nix super; - - # stdenvOverrides is used to avoid circular dependencies for building - # the standard build environment. This mechanism uses the override - # mechanism to implement some staged compilation of the stdenv. - # - # We don't want stdenv overrides in the case of cross-building, or - # otherwise the basic overridden packages will not be built with the - # crossStdenv adapter. - stdenvOverrides = self: super: - lib.optionalAttrs (crossSystem == null && super.stdenv ? overrides) - (super.stdenv.overrides super); - - customOverrides = self: super: - lib.optionalAttrs (bootStdenv == null) (overrider self super); - in - lib.fix' ( - lib.extends customOverrides ( - lib.extends stdenvOverrides ( - lib.extends aliases ( - lib.extends allPackages ( - lib.extends stdenvDefault ( - lib.extends trivialBuilders ( - lib.extends stdenvAdapters ( - self: {})))))))); -in - pkgs + configOverrides = self: super: + lib.optionalAttrs (bootStdenv == null) + ((config.packageOverrides or (super: {})) super); + + # The complete chain of package set builders, applied from bottom to top + toFix = lib.fold lib.extends (self: {}) [ + configOverrides + stdenvOverrides + aliases + allPackages + stdenvDefault + trivialBuilders + stdenvAdapters + ]; + + # Use `overridePackages` to easily override this package set. + # Warning: this function is very expensive and must not be used + # from within the nixpkgs repository. + # + # Example: + # pkgs.overridePackages (self: super: { + # foo = super.foo.override { ... }; + # } + # + # The result is `pkgs' where all the derivations depending on `foo' + # will use the new version. + + # Return the complete set of packages. Warning: this function is very + # expensive! + pkgs = lib.makeExtensibleWithCustomName "overridePackages" toFix; +in pkgs |