Add function callPackagesWith
This is like callPackageWith, except that it expects the supplied function to return a *set* of packages. It will then make the individual packages overridable.
This commit is contained in:
parent
314e8e49ec
commit
b89b6b2a7b
|
@ -1,6 +1,8 @@
|
||||||
let
|
let
|
||||||
|
|
||||||
lib = import ./default.nix;
|
lib = import ./default.nix;
|
||||||
inherit (builtins) attrNames isFunction;
|
inherit (builtins) attrNames isFunction;
|
||||||
|
|
||||||
in
|
in
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
@ -90,12 +92,28 @@ rec {
|
||||||
*/
|
*/
|
||||||
callPackageWith = autoArgs: fn: args:
|
callPackageWith = autoArgs: fn: args:
|
||||||
let
|
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;
|
auto = builtins.intersectAttrs (builtins.functionArgs f) autoArgs;
|
||||||
in makeOverridable f (auto // args);
|
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:
|
addPassthru = drv: passthru:
|
||||||
let
|
let
|
||||||
outputs = drv.outputs or [ "out" ];
|
outputs = drv.outputs or [ "out" ];
|
||||||
|
|
|
@ -141,6 +141,8 @@ let
|
||||||
# below).
|
# below).
|
||||||
callPackage = newScope {};
|
callPackage = newScope {};
|
||||||
|
|
||||||
|
callPackages = lib.callPackagesWith defaultScope;
|
||||||
|
|
||||||
newScope = extra: lib.callPackageWith (defaultScope // extra);
|
newScope = extra: lib.callPackageWith (defaultScope // extra);
|
||||||
|
|
||||||
# Easily override this package set.
|
# Easily override this package set.
|
||||||
|
|
Loading…
Reference in New Issue