about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2008-08-26 15:35:00 +0000
committerEelco Dolstra <eelco.dolstra@logicblox.com>2008-08-26 15:35:00 +0000
commit6dbbd93d030f1d049c256e90a6525c5eddd49e7e (patch)
treea450287a7e5458a4a4b725dc5435859b61af4c61
parent698328c2af65262569021cba79bef8069b317f87 (diff)
downloadnixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.tar
nixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.tar.gz
nixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.tar.bz2
nixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.tar.lz
nixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.tar.xz
nixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.tar.zst
nixlib-6dbbd93d030f1d049c256e90a6525c5eddd49e7e.zip
* Allow packages to be overriden globally via the `packageOverrides'
  configuration option.  For instance, to override GCC globally for
  all of Nixpkgs, you can put the following in ~/.nixpkgs/config.nix:

  {
    packageOverrides = pkgs: {
      gcc = pkgs.gcc41;
    }
  }

  This should make a lot of configuration support in Nixpkgs
  unnecessary, like selectVersion and many little-used configuration
  options.

  It also provides a somewhat convenient place to put custom,
  private additions to Nixpkgs, e.g.

  {
    packageOverrides = pkgs: {
      myHello = pkgs.stdenv.mkDerivation {
        name = "my-hello-0.1";
        buildCommand = ...;
      };
    };
  };

  Note that this requires Nix >= 0.12pre12726.

* Removed the `myPackages' option `packageOverrides' obsoletes it.

svn path=/nixpkgs/trunk/; revision=12727
-rw-r--r--pkgs/top-level/all-packages.nix79
1 files changed, 49 insertions, 30 deletions
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 4ae1c298c35e..68d2741363f5 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -29,7 +29,53 @@
 }:
 
 
-let pkgs = rec {
+let
+
+  lib = import ../lib;
+
+  # The contents of the configuration file found at $NIXPKGS_CONFIG or
+  # $HOME/.nixpkgs/config.nix.
+  config =
+    let {
+      toPath = builtins.toPath;
+      getEnv = x: if builtins ? getEnv then builtins.getEnv x else "";
+      pathExists = name:
+        builtins ? pathExists && builtins.pathExists (toPath name);
+
+      configFile = getEnv "NIXPKGS_CONFIG";
+      homeDir = getEnv "HOME";
+      configFile2 = homeDir + "/.nixpkgs/config.nix";
+
+      body =
+        if configFile != "" && pathExists configFile
+        then import (toPath configFile)
+        else if homeDir != "" && pathExists configFile2
+        then import (toPath configFile2)
+        else {};
+    };
+
+  # Return an attribute from the Nixpkgs configuration file, or
+  # a default value if the attribute doesn't exist.
+  getConfig = attrPath: default: lib.getAttr attrPath default config;
+
+
+  # Allow packages to be overriden globally via the `packageOverrides'
+  # 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;
+
+
+  # The package compositions.  Yes, this isn't properly indented.
+  pkgs = rec {
+
+
+  inherit __overrides;
+
+
+  # For convenience, allow callers to get the path to Nixpkgs.
+  path = ./..;
 
   
   ### Symbolic names.
@@ -47,6 +93,8 @@ let pkgs = rec {
   ### Helper functions.
 
 
+  inherit lib config getConfig;
+  
   # Override the compiler in stdenv for specific packages.
   overrideGCC = stdenv: gcc: stdenv //
     { mkDerivation = args: stdenv.mkDerivation (args // { NIX_GCC = gcc; });
@@ -151,12 +199,6 @@ let pkgs = rec {
   useFromStdenv = it : alternative : if (builtins.hasAttr it stdenv) then
     (builtins.getAttr it stdenv) else alternative;
 
-  lib = import ../lib;
-
-  # Return an attribute from the Nixpkgs configuration file, or
-  # a default value if the attribute doesn't exist.
-  getConfig = attrPath: default: lib.getAttr attrPath default config;
-
   # Return the first available value in the order: pkg.val, val, or default.
   getPkgConfig = pkg : val : default : (getConfig [ pkg val ] (getConfig [ val ] default));
 
@@ -183,27 +225,6 @@ let pkgs = rec {
     version = getConfig [ "environment" "versions" name ];
   };
 
-  # The contents of the configuration file found at $NIXPKGS_CONFIG or
-  # $HOME/.nixpkgs/config.nix.
-  config =
-    let {
-      toPath = builtins.toPath;
-      getEnv = x: if builtins ? getEnv then builtins.getEnv x else "";
-      pathExists = name:
-        builtins ? pathExists && builtins.pathExists (toPath name);
-
-      configFile = getEnv "NIXPKGS_CONFIG";
-      homeDir = getEnv "HOME";
-      configFile2 = homeDir + "/.nixpkgs/config.nix";
-
-      body =
-        if configFile != "" && pathExists configFile
-        then import (toPath configFile)
-        else if homeDir != "" && pathExists configFile2
-        then import (toPath configFile2)
-        else {};
-    };
-
   # Change the symbolic name of a package for presentation purposes
   # (i.e., so that nix-env users can tell them apart).
   setName = name: drv: drv // {inherit name;};
@@ -7538,6 +7559,4 @@ let pkgs = rec {
 
   myEnvFun = import ../misc/my_env;
 
-  myPackages = recurseIntoAttrs ( ( getConfig ["myPackages"] (x : {}) ) pkgs );
-
 }; in pkgs