summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Ericson <jericson@galois.com>2016-11-02 16:39:18 -0400
committerNicolas B. Pierron <nicolas.b.pierron@gmail.com>2016-11-02 21:50:24 +0100
commita113382f2c8557ede623e392be6a294b8a6aa545 (patch)
tree035c8b7f735d175100e8388a7ef5ae37a5810a94
parent64a3317889e18776ac6ad97a7723d795e10a94ed (diff)
downloadnixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.tar
nixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.tar.gz
nixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.tar.bz2
nixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.tar.lz
nixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.tar.xz
nixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.tar.zst
nixpkgs-a113382f2c8557ede623e392be6a294b8a6aa545.zip
top-level: Use `nixpkgsFun` to avoid import ../..
-rw-r--r--pkgs/top-level/all-packages.nix8
-rw-r--r--pkgs/top-level/default.nix18
-rw-r--r--pkgs/top-level/stdenv.nix13
3 files changed, 23 insertions, 16 deletions
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 4e0efdfe5a5..fc4660108d0 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -6,6 +6,7 @@
  * Hint: ### starts category names.
  */
 { system, bootStdenv, noSysDirs, config, crossSystem, platform, lib
+, nixpkgsFun
 , ... }:
 self: pkgs:
 
@@ -35,10 +36,9 @@ in
   newScope = extra: lib.callPackageWith (defaultScope // extra);
 
   # Override system. This is useful to build i686 packages on x86_64-linux.
-  forceSystem = system: kernel: (import ../..) {
+  forceSystem = system: kernel: nixpkgsFun {
     inherit system;
     platform = platform // { kernelArch = kernel; };
-    inherit bootStdenv noSysDirs config crossSystem;
   };
 
   # Used by wine, firefox with debugging version of Flash, ...
@@ -4254,9 +4254,7 @@ in
     # load into the Ben Nanonote
     gccCross =
       let
-        pkgsCross = (import ../..) {
-          inherit system;
-          inherit bootStdenv noSysDirs config;
+        pkgsCross = nixpkgsFun {
           # Ben Nanonote system
           crossSystem = {
             config = "mipsel-unknown-linux";
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix
index c54b23853c5..7d370bec6b5 100644
--- a/pkgs/top-level/default.nix
+++ b/pkgs/top-level/default.nix
@@ -24,13 +24,12 @@
 
 , crossSystem ? null
 , platform ? null
-}:
+} @ args:
 
 
 let configExpr = config; platform_ = platform; in # rename the function arguments
 
 let
-
   lib = import ../../lib;
 
   # Allow both:
@@ -58,9 +57,20 @@ let
     else config.platform or platformAuto;
 
   topLevelArguments = {
-    inherit system bootStdenv noSysDirs config crossSystem platform lib;
+    inherit system bootStdenv noSysDirs config crossSystem platform lib nixpkgsFun;
   };
 
+  # A few packages make a new package set to draw their dependencies from.
+  # (Currently to get a cross tool chain, or forced-i686 package.) Rather than
+  # give `all-packages.nix` all the arguments to this function, even ones that
+  # don't concern it, we give it this function to "re-call" nixpkgs, inheriting
+  # whatever arguments it doesn't explicitly provide. This way,
+  # `all-packages.nix` doesn't know more than it needs too.
+  #
+  # It's OK that `args` doesn't include the defaults: they'll be
+  # deterministically inferred the same way.
+  nixpkgsFun = newArgs: import ./. (args // newArgs);
+
   stdenvAdapters = self: super:
     let res = import ../stdenv/adapters.nix self; in res // {
       stdenvAdapters = res;
@@ -71,7 +81,7 @@ let
       inherit lib; inherit (self) stdenv stdenvNoCC; inherit (self.xorg) lndir;
     });
 
-  stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) {} pkgs;
+  stdenvDefault = self: super: (import ./stdenv.nix topLevelArguments) pkgs;
 
   allPackages = self: super:
     let res = import ./all-packages.nix topLevelArguments res self;
diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix
index 9b8cf5a0309..c36b0fed091 100644
--- a/pkgs/top-level/stdenv.nix
+++ b/pkgs/top-level/stdenv.nix
@@ -1,12 +1,11 @@
-{ system, bootStdenv, crossSystem, config, platform, lib, ... }:
-self: super:
-
-with super;
+{ system, bootStdenv, crossSystem, config, platform, lib, nixpkgsFun, ... }:
+pkgs:
 
 rec {
   allStdenvs = import ../stdenv {
     inherit system platform config lib;
-    allPackages = args: import ../.. ({ inherit config system; } // args);
+    # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
+    allPackages = args: nixpkgsFun (args // { crossSystem = null; });
   };
 
   defaultStdenv = allStdenvs.stdenv // { inherit platform; };
@@ -14,14 +13,14 @@ rec {
   stdenv =
     if bootStdenv != null then (bootStdenv // {inherit platform;}) else
       if crossSystem != null then
-        stdenvCross
+        pkgs.stdenvCross
       else
         let
             changer = config.replaceStdenv or null;
         in if changer != null then
           changer {
             # We import again all-packages to avoid recursivities.
-            pkgs = import ../.. {
+            pkgs = nixpkgsFun {
               # We remove packageOverrides to avoid recursivities
               config = removeAttrs config [ "replaceStdenv" ];
             };