diff options
Diffstat (limited to 'pkgs/lib')
-rw-r--r-- | pkgs/lib/customisation.nix | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/pkgs/lib/customisation.nix b/pkgs/lib/customisation.nix index 41af26edae70..7b4b390cbef3 100644 --- a/pkgs/lib/customisation.nix +++ b/pkgs/lib/customisation.nix @@ -61,6 +61,31 @@ rec { if x ? deepOverride then (x.deepOverride newArgs) else if x ? override then (x.override newArgs) else x) else x; - - + + + /* Call the package function in the file `fn' with the required + arguments automatically. The function is called with the + arguments `args', but any missing arguments are obtained from + `autoArgs'. This function is intended to be partially + parameterised, e.g., + + callPackage = callPackageWith pkgs; + pkgs = { + libfoo = callPackage ./foo.nix { }; + libbar = callPackage ./bar.nix { }; + }; + + If the `libbar' function expects an argument named `libfoo', it is + automatically passed as an argument. Overrides or missing + arguments can be supplied in `args', e.g. + + libbar = callPackage ./bar.nix { + libfoo = null; + enableX11 = true; + }; + */ + callPackageWith = autoArgs: fn: args: + let f = import fn; in + makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) autoArgs) // args); + } |