summary refs log tree commit diff
diff options
context:
space:
mode:
authorJohn Ericson <Ericson2314@Yahoo.com>2016-11-06 21:27:38 -0800
committerJohn Ericson <Ericson2314@Yahoo.com>2016-11-06 21:27:38 -0800
commite22346c35ee8cb872d0587320083ba44230bd44b (patch)
tree9a3d7d72b09a13bc195e03389a80e51642f95b65
parenteed34bd214d6f513a859f3cfc52b266a9d19898b (diff)
downloadnixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.tar
nixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.tar.gz
nixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.tar.bz2
nixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.tar.lz
nixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.tar.xz
nixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.tar.zst
nixpkgs-e22346c35ee8cb872d0587320083ba44230bd44b.zip
top-level: Make stdenvCross which appears at first glance normal...
...but actually is weird just like the original
-rw-r--r--pkgs/stdenv/cross/default.nix27
-rw-r--r--pkgs/stdenv/default.nix7
-rw-r--r--pkgs/top-level/default.nix7
-rw-r--r--pkgs/top-level/stdenv.nix33
4 files changed, 52 insertions, 22 deletions
diff --git a/pkgs/stdenv/cross/default.nix b/pkgs/stdenv/cross/default.nix
new file mode 100644
index 00000000000..d78061db712
--- /dev/null
+++ b/pkgs/stdenv/cross/default.nix
@@ -0,0 +1,27 @@
+{ system, allPackages, platform, crossSystem, config, ... } @ args:
+
+rec {
+  vanillaStdenv = (import ../. (args // {
+    crossSystem = null;
+    allPackages = args: allPackages ({ crossSystem = null; } // args);
+  })).stdenv;
+
+  # Yeah this isn't so cleanly just build-time packages yet. Notice the
+  # buildPackages <-> stdenvCross cycle. Yup, it's very weird.
+  #
+  # This works because the derivation used to build `stdenvCross` are in
+  # fact using `forceNativeDrv` to use the `nativeDrv` attribute of the resulting
+  # derivation built with `vanillaStdenv` (second argument of `makeStdenvCross`).
+  #
+  # Eventually, `forceNativeDrv` should be removed and the cycle broken.
+  buildPackages = allPackages {
+    # It's OK to change the built-time dependencies
+    allowCustomOverrides = true;
+    bootStdenv = stdenvCross;
+    inherit system platform crossSystem config;
+  };
+
+  stdenvCross = buildPackages.makeStdenvCross
+    vanillaStdenv crossSystem
+    buildPackages.binutilsCross buildPackages.gccCrossStageFinal;
+}
diff --git a/pkgs/stdenv/default.nix b/pkgs/stdenv/default.nix
index 3035d87e1fc..59088bfdf3b 100644
--- a/pkgs/stdenv/default.nix
+++ b/pkgs/stdenv/default.nix
@@ -5,7 +5,7 @@
 # Posix utilities, the GNU C compiler, and so on.  On other systems,
 # we use the native C library.
 
-{ system, allPackages ? import ../.., platform, config, lib }:
+{ system, allPackages ? import ../.., platform, config, crossSystem, lib }:
 
 
 rec {
@@ -36,10 +36,13 @@ rec {
   # Linux standard environment.
   inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux;
 
-  inherit (import ./darwin { inherit system allPackages platform config;}) stdenvDarwin;
+  inherit (import ./darwin { inherit system allPackages platform config; }) stdenvDarwin;
+
+  inherit (import ./cross { inherit system allPackages platform crossSystem config lib; }) stdenvCross;
 
   # Select the appropriate stdenv for the platform `system'.
   stdenv =
+    if crossSystem != null then stdenvCross else
     if system == "i686-linux" then stdenvLinux else
     if system == "x86_64-linux" then stdenvLinux else
     if system == "armv5tel-linux" then stdenvLinux else
diff --git a/pkgs/top-level/default.nix b/pkgs/top-level/default.nix
index baf314edece..73fe58ca7f3 100644
--- a/pkgs/top-level/default.nix
+++ b/pkgs/top-level/default.nix
@@ -12,6 +12,11 @@
   # null, the default standard environment is used.
   bootStdenv ? null
 
+, # This is used because stdenv replacement and the stdenvCross do benefit from
+  # the overridden configuration provided by the user, as opposed to the normal
+  # bootstrapping stdenvs.
+  allowCustomOverrides ? (bootStdenv == null)
+
 , # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
   # outside of the store.  Thus, GCC, GFortran, & co. must always look for
   # files in standard system directories (/usr/include, etc.)
@@ -109,7 +114,7 @@ let
   # attributes to refer to the original attributes (e.g. "foo =
   # ... pkgs.foo ...").
   configOverrides = self: super:
-    lib.optionalAttrs (bootStdenv == null)
+    lib.optionalAttrs allowCustomOverrides
       ((config.packageOverrides or (super: {})) super);
 
   # The complete chain of package set builders, applied from top to bottom
diff --git a/pkgs/top-level/stdenv.nix b/pkgs/top-level/stdenv.nix
index f9ba5e7516e..20f20186959 100644
--- a/pkgs/top-level/stdenv.nix
+++ b/pkgs/top-level/stdenv.nix
@@ -2,28 +2,23 @@
 
 rec {
   allStdenvs = import ../stdenv {
-    inherit system platform config lib;
-    # TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
-    allPackages = args: nixpkgsFun (args // { crossSystem = null; });
+    inherit system platform config crossSystem lib;
+    allPackages = nixpkgsFun;
   };
 
   defaultStdenv = allStdenvs.stdenv // { inherit platform; };
 
   stdenv =
-    if bootStdenv != null then (bootStdenv // {inherit platform;}) else
-      if crossSystem != null then
-        pkgs.stdenvCross
-      else
-        let
-            changer = config.replaceStdenv or null;
-        in if changer != null then
-          changer {
-            # We import again all-packages to avoid recursivities.
-            pkgs = nixpkgsFun {
-              # We remove packageOverrides to avoid recursivities
-              config = removeAttrs config [ "replaceStdenv" ];
-            };
-          }
-      else
-        defaultStdenv;
+    if bootStdenv != null then
+      (bootStdenv // { inherit platform; })
+    else if crossSystem == null && config ? replaceStdenv then
+      config.replaceStdenv {
+        # We import again all-packages to avoid recursivities.
+        pkgs = nixpkgsFun {
+          # We remove packageOverrides to avoid recursivities
+          config = removeAttrs config [ "replaceStdenv" ];
+        };
+      }
+    else
+      defaultStdenv;
 }