* Allow the Nixpkgs config to be passed as a function argument (rather

than through ~/.nixpkgs/config.nix or $NIXPKGS_CONFIG).

svn path=/nixpkgs/trunk/; revision=16861
This commit is contained in:
Eelco Dolstra 2009-08-26 13:51:37 +00:00
parent 781a112230
commit 24487fa73e

View file

@ -29,9 +29,15 @@
, gccWithCC ? true
, gccWithProfiling ? true
, # Allow a configuration attribute set to be passed in as an
# argument. Otherwise, it's read from $NIXPKGS_CONFIG or
# ~/.nixpkgs/config.nix.
config ? null
}:
let config_ = config; in # rename the function argument
let
lib = import ../lib; # see also libTests below
@ -39,7 +45,7 @@ let
# The contents of the configuration file found at $NIXPKGS_CONFIG or
# $HOME/.nixpkgs/config.nix.
config =
let {
let
toPath = builtins.toPath;
getEnv = x: if builtins ? getEnv then builtins.getEnv x else "";
pathExists = name:
@ -50,19 +56,18 @@ let
configFile2 = homeDir + "/.nixpkgs/config.nix";
configExpr =
if configFile != "" && pathExists configFile
then import (toPath configFile)
else if homeDir != "" && pathExists configFile2
then import (toPath configFile2)
if config_ != null then config_
else if configFile != "" && pathExists configFile then import (toPath configFile)
else if homeDir != "" && pathExists configFile2 then import (toPath configFile2)
else {};
in
# allow both:
# { /* the config */ } and
# { pkgsOrig, pkgs, ... } : { /* the config */ }
body = if builtins.isFunction configExpr
if builtins.isFunction configExpr
then configExpr { inherit pkgs pkgsOrig; }
else configExpr;
};
# Return an attribute from the Nixpkgs configuration file, or
# a default value if the attribute doesn't exist.
@ -200,7 +205,7 @@ let
allStdenvs = import ../stdenv {
inherit system stdenvType;
allPackages = import ./all-packages.nix;
allPackages = args: import ./all-packages.nix ({ inherit config; } // args);
};
defaultStdenv = allStdenvs.stdenv;
@ -1075,7 +1080,6 @@ let
inherit fetchurl stdenv;
};
netpbm = import ../tools/graphics/netpbm {
inherit stdenv fetchsvn libjpeg libpng zlib flex perl libxml2;
};