summary refs log tree commit diff
path: root/pkgs/lib/customisation.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2010-08-02 13:57:57 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2010-08-02 13:57:57 +0000
commitfd268b4852d39c18e604c584dd49a611dc795a9b (patch)
tree735b9815cd2e4d6c74a6124e81b59b7d5bfdd304 /pkgs/lib/customisation.nix
parent9ef0f1b93532be0c006f266f482d841ef4b25a0e (diff)
downloadnixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.tar
nixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.tar.gz
nixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.tar.bz2
nixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.tar.lz
nixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.tar.xz
nixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.tar.zst
nixpkgs-fd268b4852d39c18e604c584dd49a611dc795a9b.zip
* Add callPackage etc.
svn path=/nixpkgs/trunk/; revision=22876
Diffstat (limited to 'pkgs/lib/customisation.nix')
-rw-r--r--pkgs/lib/customisation.nix29
1 files changed, 27 insertions, 2 deletions
diff --git a/pkgs/lib/customisation.nix b/pkgs/lib/customisation.nix
index 41af26edae7..7b4b390cbef 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);
+
 }