diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-28 21:35:17 +0200 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-07-28 21:42:25 +0200 |
commit | b89b6b2a7b397a087149f01a9fd27876edfc6986 (patch) | |
tree | 6d6cbc888e364bea60b445fbf2d5f33f83ced729 /lib/customisation.nix | |
parent | 314e8e49ecbfd4136463eff782190035d1b07365 (diff) | |
download | nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.tar nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.tar.gz nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.tar.bz2 nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.tar.lz nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.tar.xz nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.tar.zst nixpkgs-b89b6b2a7b397a087149f01a9fd27876edfc6986.zip |
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.
Diffstat (limited to 'lib/customisation.nix')
-rw-r--r-- | lib/customisation.nix | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/customisation.nix b/lib/customisation.nix index b3c73c39be4..eaec46276b2 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" ]; |