summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/customisation.nix22
-rw-r--r--pkgs/top-level/all-packages.nix2
2 files changed, 22 insertions, 2 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix
index b3c73c39be41..eaec46276b2b 100644
--- a/lib/customisation.nix
+++ b/lib/customisation.nix
@@ -1,6 +1,8 @@
let
+
lib = import ./default.nix;
inherit (builtins) attrNames isFunction;
+
in
rec {
@@ -90,12 +92,28 @@ rec {
*/
callPackageWith = autoArgs: fn: args:
let
- f = if builtins.isFunction fn then fn else import fn;
+ f = if builtins.isFunction fn then fn else import fn;
auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
in makeOverridable f (auto // args);
- /* Add attributes to each output of a derivation without changing the derivation itself */
+ /* Like callPackage, but for a function that returns an attribute
+ set of derivations. The override function is added to the
+ individual attributes. */
+ callPackagesWith = autoArgs: fn: args:
+ let
+ f = if builtins.isFunction fn then fn else import fn;
+ auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
+ finalArgs = auto // args;
+ pkgs = f finalArgs;
+ mkAttrOverridable = name: pkg: pkg // {
+ override = newArgs: mkAttrOverridable name (f (finalArgs // newArgs)).${name};
+ };
+ in lib.mapAttrs mkAttrOverridable pkgs;
+
+
+ /* Add attributes to each output of a derivation without changing
+ the derivation itself. */
addPassthru = drv: passthru:
let
outputs = drv.outputs or [ "out" ];
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index b8a389aa70f7..db99800a8da4 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -141,6 +141,8 @@ let
# below).
callPackage = newScope {};
+ callPackages = lib.callPackagesWith defaultScope;
+
newScope = extra: lib.callPackageWith (defaultScope // extra);
# Easily override this package set.