diff options
author | Thomas Tuegel <ttuegel@gmail.com> | 2015-09-27 09:45:23 -0500 |
---|---|---|
committer | Thomas Tuegel <ttuegel@gmail.com> | 2015-09-27 09:45:23 -0500 |
commit | f9e5745efa96057c7c71f4956e225ffc961760d5 (patch) | |
tree | 8ace1a9acbd5e6eab4fecbf072356d35c14946cd /lib | |
parent | d15e437cff9167d263164abf702783f82b43c71d (diff) | |
download | nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.tar nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.tar.gz nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.tar.bz2 nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.tar.lz nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.tar.xz nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.tar.zst nixpkgs-f9e5745efa96057c7c71f4956e225ffc961760d5.zip |
lib: add makeScope
Diffstat (limited to 'lib')
-rw-r--r-- | lib/customisation.nix | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix index eaec46276b2..585495469b2 100644 --- a/lib/customisation.nix +++ b/lib/customisation.nix @@ -164,4 +164,23 @@ rec { drv' = (lib.head outputsList).value; in lib.deepSeq drv' drv'; + /* Make a set of packages with a common scope. All packages called + with the provided `callPackage' will be evaluated with the same + arguments. Any package in the set may depend on any other. The + `override' function allows subsequent modification of the package + set in a consistent way, i.e. all packages in the set will be + called with the overridden packages. The package sets may be + hierarchical: the packages in the set are called with the scope + provided by `newScope' and the set provides a `newScope' attribute + which can form the parent scope for later package sets. */ + makeScope = newScope: f: + let self = f self // { + newScope = scope: newScope (self // scope); + callPackage = self.newScope {}; + override = g: makeScope newScope (self_: + let super = f self_; + in super // g super self_); + }; + in self; + } |