top-level: Make stdenvCross which appears at first glance normal...
...but actually is weird just like the original
This commit is contained in:
parent
eed34bd214
commit
e22346c35e
27
pkgs/stdenv/cross/default.nix
Normal file
27
pkgs/stdenv/cross/default.nix
Normal file
|
@ -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;
|
||||||
|
}
|
|
@ -5,7 +5,7 @@
|
||||||
# Posix utilities, the GNU C compiler, and so on. On other systems,
|
# Posix utilities, the GNU C compiler, and so on. On other systems,
|
||||||
# we use the native C library.
|
# we use the native C library.
|
||||||
|
|
||||||
{ system, allPackages ? import ../.., platform, config, lib }:
|
{ system, allPackages ? import ../.., platform, config, crossSystem, lib }:
|
||||||
|
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
@ -36,10 +36,13 @@ rec {
|
||||||
# Linux standard environment.
|
# Linux standard environment.
|
||||||
inherit (import ./linux { inherit system allPackages platform config lib; }) stdenvLinux;
|
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'.
|
# Select the appropriate stdenv for the platform `system'.
|
||||||
stdenv =
|
stdenv =
|
||||||
|
if crossSystem != null then stdenvCross else
|
||||||
if system == "i686-linux" then stdenvLinux else
|
if system == "i686-linux" then stdenvLinux else
|
||||||
if system == "x86_64-linux" then stdenvLinux else
|
if system == "x86_64-linux" then stdenvLinux else
|
||||||
if system == "armv5tel-linux" then stdenvLinux else
|
if system == "armv5tel-linux" then stdenvLinux else
|
||||||
|
|
|
@ -12,6 +12,11 @@
|
||||||
# null, the default standard environment is used.
|
# null, the default standard environment is used.
|
||||||
bootStdenv ? null
|
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
|
, # Non-GNU/Linux OSes are currently "impure" platforms, with their libc
|
||||||
# outside of the store. Thus, GCC, GFortran, & co. must always look for
|
# outside of the store. Thus, GCC, GFortran, & co. must always look for
|
||||||
# files in standard system directories (/usr/include, etc.)
|
# files in standard system directories (/usr/include, etc.)
|
||||||
|
@ -109,7 +114,7 @@ let
|
||||||
# attributes to refer to the original attributes (e.g. "foo =
|
# attributes to refer to the original attributes (e.g. "foo =
|
||||||
# ... pkgs.foo ...").
|
# ... pkgs.foo ...").
|
||||||
configOverrides = self: super:
|
configOverrides = self: super:
|
||||||
lib.optionalAttrs (bootStdenv == null)
|
lib.optionalAttrs allowCustomOverrides
|
||||||
((config.packageOverrides or (super: {})) super);
|
((config.packageOverrides or (super: {})) super);
|
||||||
|
|
||||||
# The complete chain of package set builders, applied from top to bottom
|
# The complete chain of package set builders, applied from top to bottom
|
||||||
|
|
|
@ -2,28 +2,23 @@
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
allStdenvs = import ../stdenv {
|
allStdenvs = import ../stdenv {
|
||||||
inherit system platform config lib;
|
inherit system platform config crossSystem lib;
|
||||||
# TODO(@Ericson2314): hack for cross-compiling until I clean that in follow-up PR
|
allPackages = nixpkgsFun;
|
||||||
allPackages = args: nixpkgsFun (args // { crossSystem = null; });
|
|
||||||
};
|
};
|
||||||
|
|
||||||
defaultStdenv = allStdenvs.stdenv // { inherit platform; };
|
defaultStdenv = allStdenvs.stdenv // { inherit platform; };
|
||||||
|
|
||||||
stdenv =
|
stdenv =
|
||||||
if bootStdenv != null then (bootStdenv // {inherit platform;}) else
|
if bootStdenv != null then
|
||||||
if crossSystem != null then
|
(bootStdenv // { inherit platform; })
|
||||||
pkgs.stdenvCross
|
else if crossSystem == null && config ? replaceStdenv then
|
||||||
else
|
config.replaceStdenv {
|
||||||
let
|
# We import again all-packages to avoid recursivities.
|
||||||
changer = config.replaceStdenv or null;
|
pkgs = nixpkgsFun {
|
||||||
in if changer != null then
|
# We remove packageOverrides to avoid recursivities
|
||||||
changer {
|
config = removeAttrs config [ "replaceStdenv" ];
|
||||||
# We import again all-packages to avoid recursivities.
|
};
|
||||||
pkgs = nixpkgsFun {
|
}
|
||||||
# We remove packageOverrides to avoid recursivities
|
else
|
||||||
config = removeAttrs config [ "replaceStdenv" ];
|
defaultStdenv;
|
||||||
};
|
|
||||||
}
|
|
||||||
else
|
|
||||||
defaultStdenv;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue