summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-08-26 16:50:33 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-08-26 16:50:33 +0000
commit5e5eeedaa6ce5a76dc82950c7e21dc237214be73 (patch)
treea16359064a27e64636c82787ad185ecf4817f3c7
parent6dbbd93d030f1d049c256e90a6525c5eddd49e7e (diff)
downloadnixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.tar
nixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.tar.gz
nixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.tar.bz2
nixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.tar.lz
nixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.tar.xz
nixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.tar.zst
nixpkgs-5e5eeedaa6ce5a76dc82950c7e21dc237214be73.zip
* Quick proof-of-concept of making it easy to override package
  configuration options in ~/.nixpkgs/config.nix.  Example:

  {
    packageOverrides = pkgs: {
      subversion = pkgs.subversion.function (origArgs: {
        bdbSupport = false;
        pythonBindings = !origArgs.pythonBindings;
      });
    };
  }

  I.e. pkgs.subversion.function is the original function call to the
  Subversion function in all-packages.nix.

  This requires the "subversion" attribute to use makeOverridable,
  which stores the original function and function arguments in the
  "function" attribute of the result.

svn path=/nixpkgs/trunk/; revision=12728
-rw-r--r--pkgs/top-level/all-packages.nix22
1 files changed, 17 insertions, 5 deletions
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 68d2741363f..d018c3c5f40 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -63,12 +63,20 @@ let
   # configuration option, which must be a function that takes `pkgs'
   # as an argument and returns a set of new or overriden packages.
   # `__overrides' is a magic attribute that causes the attributes in
-  # its value to be added to the surrounding `rec'.
-  __overrides = (getConfig ["packageOverrides"] (pkgs: {})) pkgs;
-
+  # its value to be added to the surrounding `rec'.  The
+  # `packageOverrides' function is called with the *original*
+  # (un-overriden) set of packages, allowing packageOverrides
+  # attributes to refer to the original attributes (e.g. "foo =
+  # ... pkgs.foo ...").
+  __overrides = (getConfig ["packageOverrides"] (pkgs: {})) pkgsOrig;
+
+  pkgsOrig = pkgsFun {}; # the un-overriden packages, passed to packageOverrides
+  pkgsOverriden = pkgsFun __overrides; # the overriden, final packages
+  pkgs = pkgsOverriden;
+  
 
   # The package compositions.  Yes, this isn't properly indented.
-  pkgs = rec {
+  pkgsFun = __overrides: rec {
 
 
   inherit __overrides;
@@ -294,7 +302,11 @@ let
     in
       import (dir + "/${pVersion}.nix") (args // { version = pVersion; });
 
+  makeOverridable = f: origArgs: f origArgs //
+    { function = newArgsFun: makeOverridable f (origArgs // (newArgsFun origArgs));
+    };
 
+    
   ### STANDARD ENVIRONMENT
 
 
@@ -6691,7 +6703,7 @@ let
 
   subversion = subversion14;
 
-  subversion14 = import ../applications/version-management/subversion-1.4.x {
+  subversion14 = makeOverridable (import ../applications/version-management/subversion-1.4.x) {
     inherit fetchurl stdenv apr aprutil expat swig zlib jdk;
     neon = neon026;
     bdbSupport = getConfig ["subversion" "bdbSupport"] true;