Merge pull request #27179 from obsidiansystems/platforms-from-stdenv

Define {build,host,target}Platform in stdenv
This commit is contained in:
John Ericson 2017-07-07 14:49:55 -04:00 committed by GitHub
commit 89fcb63326
13 changed files with 243 additions and 264 deletions

View File

@ -37,8 +37,9 @@
</para>
<para>
In Nixpkgs, these three platforms are defined as attribute sets under the names <literal>buildPlatform</literal>, <literal>hostPlatform</literal>, and <literal>targetPlatform</literal>.
All three are always defined at the top level, so one can get at them just like a dependency in a function that is imported with <literal>callPackage</literal>:
<programlisting>{ stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...</programlisting>
All three are always defined as attributes in the standard environment, and at the top level. That means one can get at them just like a dependency in a function that is imported with <literal>callPackage</literal>:
<programlisting>{ stdenv, buildPlatform, hostPlatform, fooDep, barDep, .. }: ...buildPlatform...</programlisting>, or just off <varname>stdenv</varname>:
<programlisting>{ stdenv, fooDep, barDep, .. }: ...stdenv.buildPlatform...</programlisting>.
</para>
<variablelist>
<varlistentry>

View File

@ -10,7 +10,6 @@
, zlib ? null, extraPackages ? [], extraBuildCommands ? ""
, dyld ? null # TODO: should this be a setup-hook on dyld?
, isGNU ? false, isClang ? cc.isClang or false, gnugrep ? null
, hostPlatform, targetPlatform
, runCommand ? null
}:
@ -22,12 +21,14 @@ assert !nativeTools ->
assert !(nativeLibc && noLibc);
assert (noLibc || nativeLibc) == (libc == null);
assert targetPlatform != hostPlatform -> runCommand != null;
assert stdenv.targetPlatform != stdenv.hostPlatform -> runCommand != null;
# For ghdl (the vhdl language provider to gcc) we need zlib in the wrapper.
assert cc.langVhdl or false -> zlib != null;
let
inherit (stdenv) hostPlatform targetPlatform;
# Prefix for binaries. Customarily ends with a dash separator.
#
# TODO(@Ericson2314) Make unconditional, or optional but always true by

View File

@ -61,11 +61,9 @@ rec {
, buildPlatform, hostPlatform, targetPlatform
} @ overrideArgs: let
stdenv = overrideArgs.stdenv.override {
# TODO(@Ericson2314): Cannot do this for now because then Nix thinks the
# resulting derivation should be built on the host platform.
#hostPlatform = buildPlatform;
#targetPlatform = hostPlatform;
inherit cc;
inherit
buildPlatform hostPlatform targetPlatform
cc;
allowedRequisites = null;

View File

@ -14,21 +14,18 @@ in bootStages ++ [
# Build Packages
(vanillaPackages: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = crossSystem;
inherit config overlays;
selfBuild = false;
stdenv =
assert vanillaPackages.hostPlatform == localSystem;
assert vanillaPackages.targetPlatform == localSystem;
vanillaPackages.stdenv.override { targetPlatform = crossSystem; };
# It's OK to change the built-time dependencies
allowCustomOverrides = true;
inherit (vanillaPackages) stdenv;
})
# Run Packages
(buildPackages: {
buildPlatform = localSystem;
hostPlatform = crossSystem;
targetPlatform = crossSystem;
inherit config overlays;
selfBuild = false;
stdenv = buildPackages.makeStdenvCross {

View File

@ -15,11 +15,11 @@ in bootStages ++ [
# Additional stage, built using custom stdenv
(vanillaPackages: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = config.replaceStdenv { pkgs = vanillaPackages; };
stdenv =
assert vanillaPackages.hostPlatform == localSystem;
assert vanillaPackages.targetPlatform == localSystem;
config.replaceStdenv { pkgs = vanillaPackages; };
})
]

View File

@ -65,6 +65,10 @@ in rec {
name = "stdenv-darwin-boot-${toString step}";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
cc = if isNull last then "/dev/null" else import ../../build-support/cc-wrapper {
inherit shell;
inherit (last) stdenv;
@ -73,8 +77,6 @@ in rec {
nativeTools = true;
nativePrefix = bootstrapTools;
nativeLibc = false;
hostPlatform = localSystem;
targetPlatform = localSystem;
libc = last.pkgs.darwin.Libsystem;
isClang = true;
cc = { name = "clang-9.9.9"; outPath = bootstrapTools; };
@ -90,9 +92,6 @@ in rec {
'';
initialPath = [ bootstrapTools ];
hostPlatform = localSystem;
targetPlatform = localSystem;
fetchurlBoot = import ../../build-support/fetchurl {
stdenv = stage0.stdenv;
curl = bootstrapTools;
@ -107,9 +106,6 @@ in rec {
};
in {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = thisStdenv;
};
@ -279,6 +275,10 @@ in rec {
name = "stdenv-darwin";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
preHook = commonPreHook + ''
export PATH_LOCALE=${pkgs.darwin.locale}/share/locale
'';
@ -286,9 +286,6 @@ in rec {
stdenvSandboxProfile = binShClosure + libSystemProfile;
extraSandboxProfile = binShClosure + libSystemProfile;
hostPlatform = localSystem;
targetPlatform = localSystem;
initialPath = import ../common-path.nix { inherit pkgs; };
shell = "${pkgs.bash}/bin/bash";
@ -297,8 +294,6 @@ in rec {
inherit shell;
nativeTools = false;
nativeLibc = false;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit (pkgs) coreutils binutils gnugrep;
inherit (pkgs.darwin) dyld;
cc = pkgs.llvmPackages.clang-unwrapped;
@ -338,9 +333,6 @@ in rec {
stage3
stage4
(prevStage: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = stdenvDarwin prevStage;
})

View File

@ -35,6 +35,9 @@ let inherit (localSystem) system; in
stdenv = import ../generic {
name = "stdenv-freebsd-boot-1";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
initialPath = [ "/" "/usr" ];
hostPlatform = localSystem;
@ -52,6 +55,9 @@ let inherit (localSystem) system; in
stdenv = import ../generic {
name = "stdenv-freebsd-boot-0";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
initialPath = [ prevStage.bootstrapTools ];
inherit (prevStage.stdenv)
@ -62,12 +68,12 @@ let inherit (localSystem) system; in
})
(prevStage: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = import ../generic {
name = "stdenv-freebsd-boot-3";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
inherit (prevStage.stdenv)
@ -77,8 +83,6 @@ let inherit (localSystem) system; in
nativeTools = true;
nativePrefix = "/usr";
nativeLibc = true;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit (prevStage) stdenv;
cc = {
name = "clang-9.9.9";

View File

@ -15,20 +15,32 @@ let lib = import ../../../lib; in lib.makeOverridable (
, stdenvSandboxProfile ? ""
, extraSandboxProfile ? ""
, # The platforms here do *not* correspond to the stage the stdenv is
# used in, but rather the previous one, in which it was built. We
# use the latter two platforms, like a cross compiler, because the
# stand environment is a build tool if you squint at it, and because
# neither of these are used when building stdenv so we know the
# build platform is irrelevant.
hostPlatform, targetPlatform
## Platform parameters
##
## The "build" "host" "target" terminology below comes from GNU Autotools. See
## its documentation for more information on what those words mean. Note that
## each should always be defined, even when not cross compiling.
##
## For purposes of bootstrapping, think of each stage as a "sliding window"
## over a list of platforms. Specifically, the host platform of the previous
## stage becomes the build platform of the current one, and likewise the
## target platform of the previous stage becomes the host platform of the
## current one.
##
, # The platform on which packages are built. Consists of `system`, a
# string (e.g.,`i686-linux') identifying the most import attributes of the
# build platform, and `platform` a set of other details.
buildPlatform
, # The platform on which packages run.
hostPlatform
, # The platform which build tools (especially compilers) build for in this stage,
targetPlatform
}:
let
inherit (targetPlatform) system;
ifDarwin = attrs: if system == "x86_64-darwin" then attrs else {};
defaultNativeBuildInputs = extraBuildInputs ++
[ ../../build-support/setup-hooks/move-docs.sh
../../build-support/setup-hooks/compress-man-pages.sh
@ -37,7 +49,7 @@ let
]
# FIXME this on Darwin; see
# https://github.com/NixOS/nixpkgs/commit/94d164dd7#commitcomment-22030369
++ lib.optional result.isLinux ../../build-support/setup-hooks/audit-tmpdir.sh
++ lib.optional hostPlatform.isLinux ../../build-support/setup-hooks/audit-tmpdir.sh
++ [
../../build-support/setup-hooks/multiple-outputs.sh
../../build-support/setup-hooks/move-sbin.sh
@ -46,157 +58,16 @@ let
cc
];
# `mkDerivation` wraps the builtin `derivation` function to
# produce derivations that use this stdenv and its shell.
#
# See also:
#
# * https://nixos.org/nixpkgs/manual/#sec-using-stdenv
# Details on how to use this mkDerivation function
#
# * https://nixos.org/nix/manual/#ssec-derivation
# Explanation about derivations in general
mkDerivation =
{ nativeBuildInputs ? []
, buildInputs ? []
, propagatedNativeBuildInputs ? []
, propagatedBuildInputs ? []
, crossConfig ? null
, meta ? {}
, passthru ? {}
, pos ? # position used in error messages and for meta.position
(if attrs.meta.description or null != null
then builtins.unsafeGetAttrPos "description" attrs.meta
else builtins.unsafeGetAttrPos "name" attrs)
, separateDebugInfo ? false
, outputs ? [ "out" ]
, __impureHostDeps ? []
, __propagatedImpureHostDeps ? []
, sandboxProfile ? ""
, propagatedSandboxProfile ? ""
, ... } @ attrs:
let
dependencies = [
(map (drv: drv.nativeDrv or drv) nativeBuildInputs)
(map (drv: drv.crossDrv or drv) buildInputs)
];
propagatedDependencies = [
(map (drv: drv.nativeDrv or drv) propagatedNativeBuildInputs)
(map (drv: drv.crossDrv or drv) propagatedBuildInputs)
];
in let
outputs' =
outputs ++
(if separateDebugInfo then assert targetPlatform.isLinux; [ "debug" ] else []);
dependencies' = let
justMap = map lib.chooseDevOutputs dependencies;
nativeBuildInputs = lib.elemAt justMap 0
++ lib.optional targetPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh;
buildInputs = lib.elemAt justMap 1
# TODO(@Ericson2314): Should instead also be appended to `nativeBuildInputs`.
++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh;
in [ nativeBuildInputs buildInputs ];
propagatedDependencies' = map lib.chooseDevOutputs propagatedDependencies;
derivationArg =
(removeAttrs attrs
["meta" "passthru" "crossAttrs" "pos"
"__impureHostDeps" "__propagatedImpureHostDeps"
"sandboxProfile" "propagatedSandboxProfile"])
// (let
# TODO(@Ericson2314): Reversing of dep lists is just temporary to avoid Darwin mass rebuild.
computedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or []) (extraBuildInputs ++ lib.concatLists (lib.reverseList dependencies'));
computedPropagatedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or []) (lib.concatLists (lib.reverseList propagatedDependencies'));
computedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (extraBuildInputs ++ lib.concatLists (lib.reverseList dependencies')));
computedPropagatedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (lib.concatLists (lib.reverseList propagatedDependencies')));
in
{
builder = attrs.realBuilder or shell;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
stdenv = result;
system = result.system;
userHook = config.stdenv.userHook or null;
__ignoreNulls = true;
nativeBuildInputs = lib.elemAt dependencies' 0;
buildInputs = lib.elemAt dependencies' 1;
propagatedNativeBuildInputs = lib.elemAt propagatedDependencies' 0;
propagatedBuildInputs = lib.elemAt propagatedDependencies' 1;
} // ifDarwin {
# TODO: remove lib.unique once nix has a list canonicalization primitive
__sandboxProfile =
let profiles = [ extraSandboxProfile ] ++ computedSandboxProfile ++ computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile sandboxProfile ];
final = lib.concatStringsSep "\n" (lib.filter (x: x != "") (lib.unique profiles));
in final;
__propagatedSandboxProfile = lib.unique (computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile ]);
__impureHostDeps = computedImpureHostDeps ++ computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps ++ __impureHostDeps ++ __extraImpureHostDeps ++ [
"/dev/zero"
"/dev/random"
"/dev/urandom"
"/bin/sh"
];
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
} // (if outputs' != [ "out" ] then {
outputs = outputs';
} else { }));
# The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not
# passed to the builder and is not a dependency. But since we
# include it in the result, it *is* available to nix-env for queries.
meta = { }
# If the packager hasn't specified `outputsToInstall`, choose a default,
# which is the name of `p.bin or p.out or p`;
# if he has specified it, it will be overridden below in `// meta`.
# Note: This default probably shouldn't be globally configurable.
# Services and users should specify outputs explicitly,
# unless they are comfortable with this default.
// { outputsToInstall =
let
outs = outputs'; # the value passed to derivation primitive
hasOutput = out: builtins.elem out outs;
in [( lib.findFirst hasOutput null (["bin" "out"] ++ outs) )];
}
// attrs.meta or {}
# Fill `meta.position` to identify the source location of the package.
// lib.optionalAttrs (pos != null)
{ position = pos.file + ":" + toString pos.line; }
;
in
lib.addPassthru
(derivation (import ./check-meta.nix
{
inherit lib config meta derivationArg;
mkDerivationArg = attrs;
inherit system; # TODO: cross-compilation?
}))
( {
overrideAttrs = f: mkDerivation (attrs // (f attrs));
inherit meta passthru;
} //
# Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the
# derivation (e.g., in assertions).
passthru);
# The stdenv that we are producing.
result =
stdenv =
derivation (
(if isNull allowedRequisites then {} else { allowedRequisites = allowedRequisites ++ defaultNativeBuildInputs; }) //
{
inherit system name;
inherit name;
# Nix itself uses the `system` field of a derivation to decide where to
# build it. This is a bit confusing for cross compilation.
inherit (buildPlatform) system;
builder = shell;
@ -206,7 +77,7 @@ let
inherit preHook initialPath shell defaultNativeBuildInputs;
}
// ifDarwin {
// lib.optionalAttrs buildPlatform.isDarwin {
__sandboxProfile = stdenvSandboxProfile;
__impureHostDeps = __stdenvImpureHostDeps;
})
@ -218,6 +89,10 @@ let
platforms = lib.platforms.all;
};
inherit buildPlatform hostPlatform targetPlatform;
inherit extraBuildInputs __extraImpureHostDeps extraSandboxProfile;
# Utility flags to test the type of platform.
inherit (hostPlatform)
isDarwin isLinux isSunOS isHurd isCygwin isFreeBSD isOpenBSD
@ -228,7 +103,9 @@ let
# Whether we should run paxctl to pax-mark binaries.
needsPax = isLinux;
inherit mkDerivation;
inherit (import ./make-derivation.nix {
inherit lib config stdenv;
}) mkDerivation;
# For convenience, bring in the library functions in lib/ so
# packages don't have to do that themselves.
@ -247,4 +124,4 @@ let
# like curl = if stdenv ? curl then stdenv.curl else ...).
// extraAttrs;
in result)
in stdenv)

View File

@ -0,0 +1,150 @@
{ lib, config, stdenv }:
rec {
# `mkDerivation` wraps the builtin `derivation` function to
# produce derivations that use this stdenv and its shell.
#
# See also:
#
# * https://nixos.org/nixpkgs/manual/#sec-using-stdenv
# Details on how to use this mkDerivation function
#
# * https://nixos.org/nix/manual/#ssec-derivation
# Explanation about derivations in general
mkDerivation =
{ nativeBuildInputs ? []
, buildInputs ? []
, propagatedNativeBuildInputs ? []
, propagatedBuildInputs ? []
, crossConfig ? null
, meta ? {}
, passthru ? {}
, pos ? # position used in error messages and for meta.position
(if attrs.meta.description or null != null
then builtins.unsafeGetAttrPos "description" attrs.meta
else builtins.unsafeGetAttrPos "name" attrs)
, separateDebugInfo ? false
, outputs ? [ "out" ]
, __impureHostDeps ? []
, __propagatedImpureHostDeps ? []
, sandboxProfile ? ""
, propagatedSandboxProfile ? ""
, ... } @ attrs:
let
dependencies = [
(map (drv: drv.nativeDrv or drv) nativeBuildInputs)
(map (drv: drv.crossDrv or drv) buildInputs)
];
propagatedDependencies = [
(map (drv: drv.nativeDrv or drv) propagatedNativeBuildInputs)
(map (drv: drv.crossDrv or drv) propagatedBuildInputs)
];
in let
outputs' =
outputs ++
(if separateDebugInfo then assert stdenv.hostPlatform.isLinux; [ "debug" ] else []);
dependencies' = let
justMap = map lib.chooseDevOutputs dependencies;
nativeBuildInputs = lib.elemAt justMap 0
++ lib.optional stdenv.hostPlatform.isWindows ../../build-support/setup-hooks/win-dll-link.sh;
buildInputs = lib.elemAt justMap 1
# TODO(@Ericson2314): Should instead also be appended to `nativeBuildInputs`.
++ lib.optional separateDebugInfo ../../build-support/setup-hooks/separate-debug-info.sh;
in [ nativeBuildInputs buildInputs ];
propagatedDependencies' = map lib.chooseDevOutputs propagatedDependencies;
derivationArg =
(removeAttrs attrs
["meta" "passthru" "crossAttrs" "pos"
"__impureHostDeps" "__propagatedImpureHostDeps"
"sandboxProfile" "propagatedSandboxProfile"])
// (let
# TODO(@Ericson2314): Reversing of dep lists is just temporary to avoid Darwin mass rebuild.
computedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or []) (stdenv.extraBuildInputs ++ lib.concatLists (lib.reverseList dependencies'));
computedPropagatedSandboxProfile =
lib.concatMap (input: input.__propagatedSandboxProfile or []) (lib.concatLists (lib.reverseList propagatedDependencies'));
computedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (stdenv.extraBuildInputs ++ lib.concatLists (lib.reverseList dependencies')));
computedPropagatedImpureHostDeps =
lib.unique (lib.concatMap (input: input.__propagatedImpureHostDeps or []) (lib.concatLists (lib.reverseList propagatedDependencies')));
in
{
builder = attrs.realBuilder or stdenv.shell;
args = attrs.args or ["-e" (attrs.builder or ./default-builder.sh)];
inherit stdenv;
inherit (stdenv) system;
userHook = config.stdenv.userHook or null;
__ignoreNulls = true;
nativeBuildInputs = lib.elemAt dependencies' 0;
buildInputs = lib.elemAt dependencies' 1;
propagatedNativeBuildInputs = lib.elemAt propagatedDependencies' 0;
propagatedBuildInputs = lib.elemAt propagatedDependencies' 1;
} // lib.optionalAttrs (stdenv.buildPlatform.isDarwin) {
# TODO: remove lib.unique once nix has a list canonicalization primitive
__sandboxProfile =
let profiles = [ stdenv.extraSandboxProfile ] ++ computedSandboxProfile ++ computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile sandboxProfile ];
final = lib.concatStringsSep "\n" (lib.filter (x: x != "") (lib.unique profiles));
in final;
__propagatedSandboxProfile = lib.unique (computedPropagatedSandboxProfile ++ [ propagatedSandboxProfile ]);
__impureHostDeps = computedImpureHostDeps ++ computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps ++ __impureHostDeps ++ stdenv.__extraImpureHostDeps ++ [
"/dev/zero"
"/dev/random"
"/dev/urandom"
"/bin/sh"
];
__propagatedImpureHostDeps = computedPropagatedImpureHostDeps ++ __propagatedImpureHostDeps;
} // (if outputs' != [ "out" ] then {
outputs = outputs';
} else { }));
# The meta attribute is passed in the resulting attribute set,
# but it's not part of the actual derivation, i.e., it's not
# passed to the builder and is not a dependency. But since we
# include it in the result, it *is* available to nix-env for queries.
meta = { }
# If the packager hasn't specified `outputsToInstall`, choose a default,
# which is the name of `p.bin or p.out or p`;
# if he has specified it, it will be overridden below in `// meta`.
# Note: This default probably shouldn't be globally configurable.
# Services and users should specify outputs explicitly,
# unless they are comfortable with this default.
// { outputsToInstall =
let
outs = outputs'; # the value passed to derivation primitive
hasOutput = out: builtins.elem out outs;
in [( lib.findFirst hasOutput null (["bin" "out"] ++ outs) )];
}
// attrs.meta or {}
# Fill `meta.position` to identify the source location of the package.
// lib.optionalAttrs (pos != null)
{ position = pos.file + ":" + toString pos.line; }
;
in
lib.addPassthru
(derivation (import ./check-meta.nix
{
inherit lib config meta derivationArg;
mkDerivationArg = attrs;
# Nix itself uses the `system` field of a derivation to decide where
# to build it. This is a bit confusing for cross compilation.
inherit (stdenv) system;
}))
( {
overrideAttrs = f: mkDerivation (attrs // (f attrs));
inherit meta passthru;
} //
# Pass through extra attributes that are not inputs, but
# should be made available to Nix expressions using the
# derivation (e.g., in assertions).
passthru);
}

View File

@ -52,8 +52,11 @@ let
let
thisStdenv = import ../generic {
inherit config extraBuildInputs;
name = "stdenv-linux-boot";
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config extraBuildInputs;
preHook =
''
# Don't patch #!/interpreter because it leads to retained
@ -64,9 +67,6 @@ let
shell = "${bootstrapTools}/bin/bash";
initialPath = [bootstrapTools];
hostPlatform = localSystem;
targetPlatform = localSystem;
fetchurlBoot = import ../../build-support/fetchurl/boot.nix {
inherit system;
};
@ -76,8 +76,6 @@ let
else lib.makeOverridable (import ../../build-support/cc-wrapper) {
nativeTools = false;
nativeLibc = false;
hostPlatform = localSystem;
targetPlatform = localSystem;
cc = prevStage.gcc-unwrapped;
isGNU = true;
libc = prevStage.glibc;
@ -99,9 +97,6 @@ let
};
in {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = thisStdenv;
};
@ -241,8 +236,6 @@ in
nativeTools = false;
nativeLibc = false;
isGNU = true;
hostPlatform = localSystem;
targetPlatform = localSystem;
cc = prevStage.gcc-unwrapped;
libc = self.glibc;
inherit (self) stdenv binutils coreutils gnugrep;
@ -263,11 +256,11 @@ in
# dependency (`nix-store -qR') on bootstrapTools or the first
# binutils built.
(prevStage: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = import ../generic rec {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
preHook = ''
@ -280,9 +273,6 @@ in
initialPath =
((import ../common-path.nix) {pkgs = prevStage;});
hostPlatform = localSystem;
targetPlatform = localSystem;
extraBuildInputs = [ prevStage.patchelf prevStage.paxctl ] ++
# Many tarballs come with obsolete config.sub/config.guess that don't recognize aarch64.
lib.optional (system == "aarch64-linux") prevStage.updateAutotoolsGnuConfigScriptsHook;

View File

@ -81,6 +81,7 @@ let
{ cc, fetchurl, extraPath ? [], overrides ? (self: super: { }) }:
import ../generic {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
@ -125,8 +126,6 @@ in
"i686-solaris" = "/usr/gnu";
"x86_64-solaris" = "/opt/local/gcc47";
}.${system} or "/usr";
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit stdenv;
};
@ -140,9 +139,6 @@ in
# First build a stdenv based only on tools outside the store.
(prevStage: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = makeStdenv {
inherit (prevStage) cc fetchurl;
@ -152,9 +148,6 @@ in
# Using that, build a stdenv that adds the xz command (which most systems
# don't have, so we mustn't rely on the native environment providing it).
(prevStage: {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config overlays;
stdenv = makeStdenv {
inherit (prevStage.stdenv) cc fetchurl;

View File

@ -10,10 +10,13 @@ bootStages ++ [
(prevStage: let
inherit (prevStage) stdenv;
in {
inherit (prevStage) buildPlatform hostPlatform targetPlatform;
inherit config overlays;
stdenv = import ../generic rec {
buildPlatform = localSystem;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit config;
preHook = ''
@ -30,8 +33,6 @@ bootStages ++ [
nativeTools = false;
nativePrefix = stdenv.lib.optionalString hostPlatform.isSunOS "/usr";
nativeLibc = true;
hostPlatform = localSystem;
targetPlatform = localSystem;
inherit stdenv;
inherit (prevStage) binutils coreutils gnugrep;
cc = prevStage.gcc.cc;

View File

@ -18,30 +18,6 @@
, # Use to reevaluate Nixpkgs; a dirty hack that should be removed
nixpkgsFun
## Platform parameters
##
## The "build" "host" "target" terminology below comes from GNU Autotools. See
## its documentation for more information on what those words mean. Note that
## each should always be defined, even when not cross compiling.
##
## For purposes of bootstrapping, think of each stage as a "sliding window"
## over a list of platforms. Specifically, the host platform of the previous
## stage becomes the build platform of the current one, and likewise the
## target platform of the previous stage becomes the host platform of the
## current one.
##
, # The platform on which packages are built. Consists of `system`, a
# string (e.g.,`i686-linux') identifying the most import attributes of the
# build platform, and `platform` a set of other details.
buildPlatform
, # The platform on which packages run.
hostPlatform
, # The platform which build tools (especially compilers) build for in this stage,
targetPlatform
## Other parameters
##
@ -69,10 +45,10 @@
, # 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.)
noSysDirs ? buildPlatform.system != "x86_64-freebsd"
&& buildPlatform.system != "i686-freebsd"
&& buildPlatform.system != "x86_64-solaris"
&& buildPlatform.system != "x86_64-kfreebsd-gnu"
noSysDirs ? stdenv.buildPlatform.system != "x86_64-freebsd"
&& stdenv.buildPlatform.system != "i686-freebsd"
&& stdenv.buildPlatform.system != "x86_64-solaris"
&& stdenv.buildPlatform.system != "x86_64-kfreebsd-gnu"
, # The configuration attribute set
config
@ -98,19 +74,18 @@ let
// { recurseForDerivations = false; };
__targetPackages = (if __targetPackages == null then self else __targetPackages)
// { recurseForDerivations = false; };
inherit stdenv
buildPlatform hostPlatform targetPlatform;
inherit stdenv;
};
# The old identifiers for cross-compiling. These should eventually be removed,
# and the packages that rely on them refactored accordingly.
platformCompat = self: super: let
# TODO(@Ericson2314) this causes infinite recursion
#inherit (self) buildPlatform hostPlatform targetPlatform;
inherit (super.stdenv) buildPlatform hostPlatform targetPlatform;
in {
stdenv = super.stdenv // {
inherit (buildPlatform) platform;
inherit (super.stdenv.buildPlatform) platform;
};
inherit buildPlatform hostPlatform targetPlatform;
inherit (buildPlatform) system platform;
};