mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 06:53:01 +00:00
top-level: Lay the groundwork for {build,host,target}Platform
The long term goal is a big replace: { inherit system platform; } => buildPlatform crossSystem => hostPlatform stdenv.cross => targetPlatform And additionally making sure each is defined even when not cross compiling. This commit refactors the bootstrapping code along that vision, but leaves the old identifiers with their null semantics in place so packages can be modernized incrementally.
This commit is contained in:
parent
5b88f09ec4
commit
92edcb7ebb
@ -108,7 +108,7 @@ rec {
|
|||||||
crossConfig = cross.config;
|
crossConfig = cross.config;
|
||||||
} // args.crossAttrs or {});
|
} // args.crossAttrs or {});
|
||||||
} // {
|
} // {
|
||||||
inherit cross gccCross binutilsCross;
|
inherit gccCross binutilsCross;
|
||||||
ccCross = gccCross;
|
ccCross = gccCross;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
bootStages = import ../. {
|
bootStages = import ../. {
|
||||||
inherit lib system platform overlays;
|
inherit lib localSystem overlays;
|
||||||
crossSystem = null;
|
crossSystem = null;
|
||||||
# Ignore custom stdenvs when cross compiling for compatability
|
# Ignore custom stdenvs when cross compiling for compatability
|
||||||
config = builtins.removeAttrs config [ "replaceStdenv" ];
|
config = builtins.removeAttrs config [ "replaceStdenv" ];
|
||||||
@ -14,21 +14,25 @@ in bootStages ++ [
|
|||||||
|
|
||||||
# Build Packages
|
# Build Packages
|
||||||
(vanillaPackages: {
|
(vanillaPackages: {
|
||||||
inherit system platform crossSystem config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = crossSystem;
|
||||||
|
inherit config overlays;
|
||||||
# Should be false, but we're trying to preserve hashes for now
|
# Should be false, but we're trying to preserve hashes for now
|
||||||
selfBuild = true;
|
selfBuild = true;
|
||||||
# It's OK to change the built-time dependencies
|
# It's OK to change the built-time dependencies
|
||||||
allowCustomOverrides = true;
|
allowCustomOverrides = true;
|
||||||
stdenv = vanillaPackages.stdenv // {
|
stdenv = vanillaPackages.stdenv // {
|
||||||
# Needed elsewhere as a hacky way to pass the target
|
|
||||||
cross = crossSystem;
|
|
||||||
overrides = _: _: {};
|
overrides = _: _: {};
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
# Run Packages
|
# Run Packages
|
||||||
(buildPackages: {
|
(buildPackages: {
|
||||||
inherit system platform crossSystem config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = crossSystem;
|
||||||
|
targetPlatform = crossSystem;
|
||||||
|
inherit config overlays;
|
||||||
selfBuild = false;
|
selfBuild = false;
|
||||||
stdenv = if crossSystem.useiOSCross or false
|
stdenv = if crossSystem.useiOSCross or false
|
||||||
then let
|
then let
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert crossSystem == null;
|
assert crossSystem == null;
|
||||||
|
|
||||||
let
|
let
|
||||||
bootStages = import ../. {
|
bootStages = import ../. {
|
||||||
inherit lib system platform crossSystem overlays;
|
inherit lib localSystem crossSystem overlays;
|
||||||
# Remove config.replaceStdenv to ensure termination.
|
# Remove config.replaceStdenv to ensure termination.
|
||||||
config = builtins.removeAttrs config [ "replaceStdenv" ];
|
config = builtins.removeAttrs config [ "replaceStdenv" ];
|
||||||
};
|
};
|
||||||
@ -15,7 +15,10 @@ in bootStages ++ [
|
|||||||
|
|
||||||
# Additional stage, built using custom stdenv
|
# Additional stage, built using custom stdenv
|
||||||
(vanillaPackages: {
|
(vanillaPackages: {
|
||||||
inherit system platform crossSystem config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = config.replaceStdenv { pkgs = vanillaPackages; };
|
stdenv = config.replaceStdenv { pkgs = vanillaPackages; };
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
|
|
||||||
# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
|
# Allow passing in bootstrap files directly so we can test the stdenv bootstrap process when changing the bootstrap tools
|
||||||
, bootstrapFiles ? let
|
, bootstrapFiles ? let
|
||||||
fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
|
fetch = { file, sha256, executable ? true }: import <nix/fetchurl.nix> {
|
||||||
url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/33f59c9d11b8d5014dfd18cc11a425f6393c884a/${file}";
|
url = "http://tarballs.nixos.org/stdenv-darwin/x86_64/33f59c9d11b8d5014dfd18cc11a425f6393c884a/${file}";
|
||||||
inherit sha256 system executable;
|
inherit (localSystem) system;
|
||||||
|
inherit sha256 executable;
|
||||||
}; in {
|
}; in {
|
||||||
sh = fetch { file = "sh"; sha256 = "1rx4kg6358xdj05z0m139a0zn4f4zfmq4n4vimlmnwyfiyn4x7wk"; };
|
sh = fetch { file = "sh"; sha256 = "1rx4kg6358xdj05z0m139a0zn4f4zfmq4n4vimlmnwyfiyn4x7wk"; };
|
||||||
bzip2 = fetch { file = "bzip2"; sha256 = "104qnhzk79vkbp2yi0kci6lszgfppvrwk3rgxhry842ly1xz2r7l"; };
|
bzip2 = fetch { file = "bzip2"; sha256 = "104qnhzk79vkbp2yi0kci6lszgfppvrwk3rgxhry842ly1xz2r7l"; };
|
||||||
@ -18,6 +19,8 @@
|
|||||||
assert crossSystem == null;
|
assert crossSystem == null;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (localSystem) system platform;
|
||||||
|
|
||||||
libSystemProfile = ''
|
libSystemProfile = ''
|
||||||
(import "${./standard-sandbox.sb}")
|
(import "${./standard-sandbox.sb}")
|
||||||
'';
|
'';
|
||||||
@ -98,7 +101,10 @@ in rec {
|
|||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
inherit system platform crossSystem config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = thisStdenv;
|
stdenv = thisStdenv;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -316,7 +322,10 @@ in rec {
|
|||||||
stage3
|
stage3
|
||||||
stage4
|
stage4
|
||||||
(prevStage: {
|
(prevStage: {
|
||||||
inherit system crossSystem platform config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = stdenvDarwin prevStage;
|
stdenv = stdenvDarwin prevStage;
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
{ # Args just for stdenvs' usage
|
{ # Args just for stdenvs' usage
|
||||||
lib
|
lib
|
||||||
# Args to pass on to the pkgset builder, too
|
# Args to pass on to the pkgset builder, too
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
} @ args:
|
} @ args:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -51,4 +51,4 @@ in
|
|||||||
"i686-cygwin" = stagesNative;
|
"i686-cygwin" = stagesNative;
|
||||||
"x86_64-cygwin" = stagesNative;
|
"x86_64-cygwin" = stagesNative;
|
||||||
"x86_64-freebsd" = stagesFreeBSD;
|
"x86_64-freebsd" = stagesFreeBSD;
|
||||||
}.${system} or stagesNative
|
}.${localSystem.system} or stagesNative
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert crossSystem == null;
|
assert crossSystem == null;
|
||||||
|
let inherit (localSystem) system; in
|
||||||
|
|
||||||
|
|
||||||
[
|
[
|
||||||
@ -58,7 +59,10 @@ assert crossSystem == null;
|
|||||||
})
|
})
|
||||||
|
|
||||||
(prevStage: {
|
(prevStage: {
|
||||||
inherit system crossSystem platform config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = import ../generic {
|
stdenv = import ../generic {
|
||||||
name = "stdenv-freebsd-boot-3";
|
name = "stdenv-freebsd-boot-3";
|
||||||
inherit system config;
|
inherit system config;
|
||||||
|
@ -4,21 +4,23 @@
|
|||||||
# compiler and linker that do not search in default locations,
|
# compiler and linker that do not search in default locations,
|
||||||
# ensuring purity of components produced by it.
|
# ensuring purity of components produced by it.
|
||||||
{ lib
|
{ lib
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
|
|
||||||
, bootstrapFiles ?
|
, bootstrapFiles ? { # switch
|
||||||
if system == "i686-linux" then import ./bootstrap-files/i686.nix
|
"i686-linux" = import ./bootstrap-files/i686.nix;
|
||||||
else if system == "x86_64-linux" then import ./bootstrap-files/x86_64.nix
|
"x86_64-linux" = import ./bootstrap-files/x86_64.nix;
|
||||||
else if system == "armv5tel-linux" then import ./bootstrap-files/armv5tel.nix
|
"armv5tel-linux" = import ./bootstrap-files/armv5tel.nix;
|
||||||
else if system == "armv6l-linux" then import ./bootstrap-files/armv6l.nix
|
"armv6l-linux" = import ./bootstrap-files/armv6l.nix;
|
||||||
else if system == "armv7l-linux" then import ./bootstrap-files/armv7l.nix
|
"armv7l-linux" = import ./bootstrap-files/armv7l.nix;
|
||||||
else if system == "mips64el-linux" then import ./bootstrap-files/loongson2f.nix
|
"mips64el-linux" = import ./bootstrap-files/loongson2f.nix;
|
||||||
else abort "unsupported platform for the pure Linux stdenv"
|
}.${localSystem.system}
|
||||||
|
or (abort "unsupported platform for the pure Linux stdenv")
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert crossSystem == null;
|
assert crossSystem == null;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (localSystem) system platform;
|
||||||
|
|
||||||
commonPreHook =
|
commonPreHook =
|
||||||
''
|
''
|
||||||
@ -91,7 +93,10 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
in {
|
in {
|
||||||
inherit system platform crossSystem config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = thisStdenv;
|
stdenv = thisStdenv;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -246,7 +251,10 @@ in
|
|||||||
# dependency (`nix-store -qR') on bootstrapTools or the first
|
# dependency (`nix-store -qR') on bootstrapTools or the first
|
||||||
# binutils built.
|
# binutils built.
|
||||||
(prevStage: {
|
(prevStage: {
|
||||||
inherit system crossSystem platform config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = import ../generic rec {
|
stdenv = import ../generic rec {
|
||||||
inherit system config;
|
inherit system config;
|
||||||
|
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{ lib
|
{ lib
|
||||||
, system, platform, crossSystem, config, overlays
|
, localSystem, crossSystem, config, overlays
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert crossSystem == null;
|
assert crossSystem == null;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (localSystem) system platform;
|
||||||
|
|
||||||
shell =
|
shell =
|
||||||
if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
|
if system == "i686-freebsd" || system == "x86_64-freebsd" then "/usr/local/bin/bash"
|
||||||
@ -134,7 +135,10 @@ in
|
|||||||
|
|
||||||
# First build a stdenv based only on tools outside the store.
|
# First build a stdenv based only on tools outside the store.
|
||||||
(prevStage: {
|
(prevStage: {
|
||||||
inherit system crossSystem platform config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = makeStdenv {
|
stdenv = makeStdenv {
|
||||||
inherit (prevStage) cc fetchurl;
|
inherit (prevStage) cc fetchurl;
|
||||||
} // { inherit (prevStage) fetchurl; };
|
} // { inherit (prevStage) fetchurl; };
|
||||||
@ -143,7 +147,10 @@ in
|
|||||||
# Using that, build a stdenv that adds the ‘xz’ command (which most systems
|
# 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).
|
# don't have, so we mustn't rely on the native environment providing it).
|
||||||
(prevStage: {
|
(prevStage: {
|
||||||
inherit system crossSystem platform config overlays;
|
buildPlatform = localSystem;
|
||||||
|
hostPlatform = localSystem;
|
||||||
|
targetPlatform = localSystem;
|
||||||
|
inherit config overlays;
|
||||||
stdenv = makeStdenv {
|
stdenv = makeStdenv {
|
||||||
inherit (prevStage.stdenv) cc fetchurl;
|
inherit (prevStage.stdenv) cc fetchurl;
|
||||||
extraPath = [ prevStage.xz ];
|
extraPath = [ prevStage.xz ];
|
||||||
|
@ -9,9 +9,9 @@ assert crossSystem == null;
|
|||||||
bootStages ++ [
|
bootStages ++ [
|
||||||
(prevStage: let
|
(prevStage: let
|
||||||
inherit (prevStage) stdenv;
|
inherit (prevStage) stdenv;
|
||||||
inherit (stdenv) system platform;
|
|
||||||
in {
|
in {
|
||||||
inherit system platform crossSystem config;
|
inherit (prevStage) buildPlatform hostPlatform targetPlatform;
|
||||||
|
inherit config overlays;
|
||||||
|
|
||||||
stdenv = import ../generic rec {
|
stdenv = import ../generic rec {
|
||||||
inherit config;
|
inherit config;
|
||||||
|
@ -83,7 +83,8 @@ in let
|
|||||||
boot = import ../stdenv/booter.nix { inherit lib allPackages; };
|
boot = import ../stdenv/booter.nix { inherit lib allPackages; };
|
||||||
|
|
||||||
stages = stdenvStages {
|
stages = stdenvStages {
|
||||||
inherit lib system platform crossSystem config overlays;
|
localSystem = { inherit system platform; };
|
||||||
|
inherit lib crossSystem config overlays;
|
||||||
};
|
};
|
||||||
|
|
||||||
pkgs = boot stages;
|
pkgs = boot stages;
|
||||||
|
@ -9,10 +9,43 @@
|
|||||||
import `pkgs/default.nix` or `default.nix`. */
|
import `pkgs/default.nix` or `default.nix`. */
|
||||||
|
|
||||||
|
|
||||||
{ # The system (e.g., `i686-linux') for which to build the packages.
|
{ ## Misc parameters kept the same for all stages
|
||||||
system
|
##
|
||||||
|
|
||||||
, # the package set used at build-time
|
# Utility functions, could just import but passing in for efficiency
|
||||||
|
lib
|
||||||
|
|
||||||
|
, # 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
|
||||||
|
##
|
||||||
|
|
||||||
|
, # The package set used at build-time
|
||||||
buildPackages
|
buildPackages
|
||||||
|
|
||||||
, # The standard environment to use for building packages.
|
, # The standard environment to use for building packages.
|
||||||
@ -24,21 +57,19 @@
|
|||||||
allowCustomOverrides
|
allowCustomOverrides
|
||||||
|
|
||||||
, # 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
|
||||||
# files in standard system directories (/usr/include, etc.)
|
# in standard system directories (/usr/include, etc.)
|
||||||
noSysDirs ? (system != "x86_64-freebsd" && system != "i686-freebsd"
|
noSysDirs ? buildPlatform.system != "x86_64-freebsd"
|
||||||
&& system != "x86_64-solaris"
|
&& buildPlatform.system != "i686-freebsd"
|
||||||
&& system != "x86_64-kfreebsd-gnu")
|
&& buildPlatform.system != "x86_64-solaris"
|
||||||
|
&& buildPlatform.system != "x86_64-kfreebsd-gnu"
|
||||||
|
|
||||||
, # The configuration attribute set
|
, # The configuration attribute set
|
||||||
config
|
config
|
||||||
|
|
||||||
, overlays # List of overlays to use in the fix-point.
|
, # A list of overlays (Additional `self: super: { .. }` customization
|
||||||
|
# functions) to be fixed together in the produced package set
|
||||||
, crossSystem
|
overlays
|
||||||
, platform
|
|
||||||
, lib
|
|
||||||
, nixpkgsFun
|
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -53,10 +84,24 @@ let
|
|||||||
};
|
};
|
||||||
|
|
||||||
stdenvBootstappingAndPlatforms = self: super: {
|
stdenvBootstappingAndPlatforms = self: super: {
|
||||||
stdenv = stdenv // { inherit platform; };
|
|
||||||
buildPackages = buildPackages // { recurseForDerivations = false; };
|
buildPackages = buildPackages // { recurseForDerivations = false; };
|
||||||
inherit
|
inherit stdenv
|
||||||
system platform crossSystem;
|
buildPlatform hostPlatform targetPlatform;
|
||||||
|
};
|
||||||
|
|
||||||
|
# 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;
|
||||||
|
in {
|
||||||
|
stdenv = super.stdenv // {
|
||||||
|
inherit (buildPlatform) platform;
|
||||||
|
} // lib.optionalAttrs (targetPlatform != buildPlatform) {
|
||||||
|
cross = targetPlatform;
|
||||||
|
};
|
||||||
|
inherit (buildPlatform) system platform;
|
||||||
|
crossSystem = if targetPlatform != buildPlatform then targetPlatform else null;
|
||||||
};
|
};
|
||||||
|
|
||||||
splice = self: super: import ./splice.nix lib self;
|
splice = self: super: import ./splice.nix lib self;
|
||||||
@ -89,6 +134,7 @@ let
|
|||||||
# The complete chain of package set builders, applied from top to bottom
|
# The complete chain of package set builders, applied from top to bottom
|
||||||
toFix = lib.foldl' (lib.flip lib.extends) (self: {}) ([
|
toFix = lib.foldl' (lib.flip lib.extends) (self: {}) ([
|
||||||
stdenvBootstappingAndPlatforms
|
stdenvBootstappingAndPlatforms
|
||||||
|
platformCompat
|
||||||
stdenvAdapters
|
stdenvAdapters
|
||||||
trivialBuilders
|
trivialBuilders
|
||||||
splice
|
splice
|
||||||
|
Loading…
Reference in New Issue
Block a user