From 24487fa73ecab0b78aefd2e0a86ff90b14abf8ba Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 26 Aug 2009 13:51:37 +0000 Subject: [PATCH] * 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 --- pkgs/top-level/all-packages.nix | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 3f857765753d..407f9e47641c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -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; };