diff options
-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; + } |