mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 16:33:15 +00:00
top-level: Introduce buildPackages
for resolving build-time deps
[N.B., this package also applies to the commits that follow it in the same PR.] In most cases, buildPackages = pkgs so things work just as before. For cross compiling, however, buildPackages is resolved as the previous bootstrapping stage. This allows us to avoid the mkDerivation hacks cross compiling currently uses today. To avoid a massive refactor, callPackage will splice together both package sets. Again to avoid churn, it uses the old `nativeDrv` vs `crossDrv` to do so. So now, whether cross compiling or not, packages with get a `nativeDrv` and `crossDrv`---in the non-cross-compiling case they are simply the same derivation. This is good because it reduces the divergence between the cross and non-cross dataflow. See `pkgs/top-level/splice.nix` for a comment along the lines of the preceding paragraph, and the code that does this splicing. Also, `forceNativeDrv` is replaced with `forceNativePackages`. The latter resolves `pkgs` unless the host platform is different from the build platform, in which case it resolves to `buildPackages`. Note that the target platform is not important here---it will not prevent `forcedNativePackages` from resolving to `pkgs`. -------- Temporarily, we make preserve some dubious decisions in the name of preserving hashes: Most importantly, we don't distinguish between "host" and "target" in the autoconf sense. This leads to the proliferation of *Cross derivations currently used. What we ought to is resolve native deps of the cross "build packages" (build = host != target) package set against the "vanilla packages" (build = host = target) package set. Instead, "build packages" uses itself, with (informally) target != build in all cases. This is wrong because it violates the "sliding window" principle of bootstrapping stages that shifting the platform triple of one stage to the left coincides with the next stage's platform triple. Only because we don't explicitly distinguish between "host" and "target" does it appear that the "sliding window" principle is preserved--indeed it is over the reductionary "platform double" of just "build" and "host/target". Additionally, we build libc, libgcc, etc in the same stage as the compilers themselves, which is wrong because they are used at runtime, not build time. Fixing this is somewhat subtle, and the solution and problem will be better explained in the commit that does fix it. Commits after this will solve both these issues, at the expense of breaking cross hashes. Native hashes won't be broken, thankfully. -------- Did the temporary ugliness pan out? Of the packages that currently build in `release-cross.nix`, the only ones that have their hash changed are `*.gcc.crossDrv` and `bootstrapTools.*.coreutilsMinimal`. In both cases I think it doesn't matter. 1. GCC when doing a `build = host = target = foreign` build (maximally cross), still defines environment variables like `CPATH`[1] with packages. This seems assuredly wrong because whether gcc dynamically links those, or the programs built by gcc dynamically link those---I have no idea which case is reality---they should be foreign. Therefore, in all likelihood, I just made the gcc less broken. 2. Coreutils (ab)used the old cross-compiling infrastructure to depend on a native version of itself. When coreutils was overwritten to be built with fewer features, the native version it used would also be overwritten because the binding was tight. Now it uses the much looser `BuildPackages.coreutils` which is just fine as a richer build dep doesn't cause any problems and avoids a rebuild. So, in conclusion I'd say the conservatism payed off. Onward to actually raking the muck in the next PR! [1]: https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html
This commit is contained in:
parent
92b1e39e1c
commit
bf17d6dacf
@ -3,7 +3,7 @@
|
|||||||
args@{ fetchgit, stdenv, autoconf, automake, automake111x, libtool
|
args@{ fetchgit, stdenv, autoconf, automake, automake111x, libtool
|
||||||
, texinfo, glibcCross, hurdPartedCross, libuuid, samba
|
, texinfo, glibcCross, hurdPartedCross, libuuid, samba
|
||||||
, gccCrossStageStatic, gccCrossStageFinal
|
, gccCrossStageStatic, gccCrossStageFinal
|
||||||
, forceNativeDrv, forceSystem, newScope, platform, config, crossSystem
|
, forcedNativePackages, forceSystem, newScope, platform, config, crossSystem
|
||||||
, overrides ? {} }:
|
, overrides ? {} }:
|
||||||
|
|
||||||
with args;
|
with args;
|
||||||
@ -12,7 +12,7 @@ let
|
|||||||
callPackage = newScope gnu;
|
callPackage = newScope gnu;
|
||||||
|
|
||||||
gnu = {
|
gnu = {
|
||||||
hurdCross = forceNativeDrv (callPackage ./hurd {
|
hurdCross = forcedNativePackages.callPackage ./hurd {
|
||||||
inherit fetchgit stdenv autoconf libtool texinfo
|
inherit fetchgit stdenv autoconf libtool texinfo
|
||||||
glibcCross hurdPartedCross;
|
glibcCross hurdPartedCross;
|
||||||
inherit (gnu) machHeaders mig;
|
inherit (gnu) machHeaders mig;
|
||||||
@ -21,9 +21,9 @@ let
|
|||||||
headersOnly = false;
|
headersOnly = false;
|
||||||
cross = assert crossSystem != null; crossSystem;
|
cross = assert crossSystem != null; crossSystem;
|
||||||
gccCross = gccCrossStageFinal;
|
gccCross = gccCrossStageFinal;
|
||||||
});
|
};
|
||||||
|
|
||||||
hurdCrossIntermediate = forceNativeDrv (callPackage ./hurd {
|
hurdCrossIntermediate = forcedNativePackages.callPackage ./hurd {
|
||||||
inherit fetchgit stdenv autoconf libtool texinfo glibcCross;
|
inherit fetchgit stdenv autoconf libtool texinfo glibcCross;
|
||||||
inherit (gnu) machHeaders mig;
|
inherit (gnu) machHeaders mig;
|
||||||
hurdPartedCross = null;
|
hurdPartedCross = null;
|
||||||
@ -42,7 +42,7 @@ let
|
|||||||
# libshouldbeinlibc.
|
# libshouldbeinlibc.
|
||||||
buildTarget = "libihash libstore libshouldbeinlibc";
|
buildTarget = "libihash libstore libshouldbeinlibc";
|
||||||
installTarget = "libihash-install libstore-install libshouldbeinlibc-install";
|
installTarget = "libihash-install libstore-install libshouldbeinlibc-install";
|
||||||
});
|
};
|
||||||
|
|
||||||
hurdHeaders = callPackage ./hurd {
|
hurdHeaders = callPackage ./hurd {
|
||||||
automake = automake111x;
|
automake = automake111x;
|
||||||
@ -58,13 +58,13 @@ let
|
|||||||
hurd = null;
|
hurd = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
libpthreadCross = forceNativeDrv (callPackage ./libpthread {
|
libpthreadCross = forcedNativePackages.callPackage ./libpthread {
|
||||||
inherit fetchgit stdenv autoconf automake libtool glibcCross;
|
inherit fetchgit stdenv autoconf automake libtool glibcCross;
|
||||||
inherit (gnu) machHeaders hurdHeaders;
|
inherit (gnu) machHeaders hurdHeaders;
|
||||||
hurd = gnu.hurdCrossIntermediate;
|
hurd = gnu.hurdCrossIntermediate;
|
||||||
gccCross = gccCrossStageStatic;
|
gccCross = gccCrossStageStatic;
|
||||||
cross = assert crossSystem != null; crossSystem;
|
cross = assert crossSystem != null; crossSystem;
|
||||||
});
|
};
|
||||||
|
|
||||||
# In theory GNU Mach doesn't have to be cross-compiled. However, since it
|
# In theory GNU Mach doesn't have to be cross-compiled. However, since it
|
||||||
# has to be built for i586 (it doesn't work on x86_64), one needs a cross
|
# has to be built for i586 (it doesn't work on x86_64), one needs a cross
|
||||||
|
@ -66,12 +66,10 @@ rec {
|
|||||||
|
|
||||||
# In nixpkgs, sometimes 'null' gets in as a buildInputs element,
|
# In nixpkgs, sometimes 'null' gets in as a buildInputs element,
|
||||||
# and we handle that through isAttrs.
|
# and we handle that through isAttrs.
|
||||||
getNativeDrv = drv: drv.nativeDrv or drv;
|
nativeBuildInputsDrvs = nativeBuildInputs;
|
||||||
getCrossDrv = drv: drv.crossDrv or drv;
|
buildInputsDrvs = buildInputs;
|
||||||
nativeBuildInputsDrvs = map getNativeDrv nativeBuildInputs;
|
propagatedBuildInputsDrvs = propagatedBuildInputs;
|
||||||
buildInputsDrvs = map getCrossDrv buildInputs;
|
propagatedNativeBuildInputsDrvs = propagatedNativeBuildInputs;
|
||||||
propagatedBuildInputsDrvs = map getCrossDrv propagatedBuildInputs;
|
|
||||||
propagatedNativeBuildInputsDrvs = map getNativeDrv propagatedNativeBuildInputs;
|
|
||||||
|
|
||||||
# The base stdenv already knows that nativeBuildInputs and
|
# The base stdenv already knows that nativeBuildInputs and
|
||||||
# buildInputs should be built with the usual gcc-wrapper
|
# buildInputs should be built with the usual gcc-wrapper
|
||||||
@ -88,10 +86,7 @@ rec {
|
|||||||
(drv: builtins.isAttrs drv && drv ? nativeDrv) buildInputs;
|
(drv: builtins.isAttrs drv && drv ? nativeDrv) buildInputs;
|
||||||
nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull;
|
nativeInputsFromBuildInputs = stdenv.lib.filter hostAsNativeDrv buildInputsNotNull;
|
||||||
|
|
||||||
# We should overwrite the input attributes in crossDrv, to overwrite
|
in stdenv.mkDerivation (args // {
|
||||||
# the defaults for only-native builds in the base stdenv
|
|
||||||
crossDrv = if cross == null then nativeDrv else
|
|
||||||
stdenv.mkDerivation (args // {
|
|
||||||
name = name + "-" + cross.config;
|
name = name + "-" + cross.config;
|
||||||
nativeBuildInputs = nativeBuildInputsDrvs
|
nativeBuildInputs = nativeBuildInputsDrvs
|
||||||
++ nativeInputsFromBuildInputs
|
++ nativeInputsFromBuildInputs
|
||||||
@ -112,9 +107,6 @@ rec {
|
|||||||
|
|
||||||
crossConfig = cross.config;
|
crossConfig = cross.config;
|
||||||
} // args.crossAttrs or {});
|
} // args.crossAttrs or {});
|
||||||
in nativeDrv // {
|
|
||||||
inherit crossDrv nativeDrv;
|
|
||||||
};
|
|
||||||
} // {
|
} // {
|
||||||
inherit cross gccCross binutilsCross;
|
inherit cross gccCross binutilsCross;
|
||||||
ccCross = gccCross;
|
ccCross = gccCross;
|
||||||
|
@ -57,12 +57,18 @@ stageFuns: let
|
|||||||
# debugging purposes.
|
# debugging purposes.
|
||||||
folder = stageFun: finalSoFar: let
|
folder = stageFun: finalSoFar: let
|
||||||
args = stageFun finalSoFar;
|
args = stageFun finalSoFar;
|
||||||
stdenv = args.stdenv // {
|
args' = args // {
|
||||||
# For debugging
|
stdenv = args.stdenv // {
|
||||||
__bootPackages = finalSoFar;
|
# For debugging
|
||||||
|
__bootPackages = finalSoFar;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
args' = args // { inherit stdenv; };
|
self =
|
||||||
in
|
if args.__raw or false
|
||||||
(if args.__raw or false then lib.id else allPackages) args';
|
then args'
|
||||||
|
else allPackages ((builtins.removeAttrs args' ["selfBuild"]) // {
|
||||||
|
buildPackages = if args.selfBuild or true then self else finalSoFar;
|
||||||
|
});
|
||||||
|
in self;
|
||||||
|
|
||||||
in lib.lists.fold folder {} withAllowCustomOverrides
|
in lib.lists.fold folder {} withAllowCustomOverrides
|
||||||
|
@ -12,13 +12,11 @@ let
|
|||||||
|
|
||||||
in bootStages ++ [
|
in bootStages ++ [
|
||||||
|
|
||||||
# Build Packages.
|
# Build Packages
|
||||||
#
|
|
||||||
# For now, this is just used to build the native stdenv. Eventually, it
|
|
||||||
# should be used to build compilers and other such tools targeting the cross
|
|
||||||
# platform. Then, `forceNativeDrv` can be removed.
|
|
||||||
(vanillaPackages: {
|
(vanillaPackages: {
|
||||||
inherit system platform crossSystem config overlays;
|
inherit system platform crossSystem config overlays;
|
||||||
|
# Should be false, but we're trying to preserve hashes for now
|
||||||
|
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 // {
|
||||||
@ -28,9 +26,10 @@ in bootStages ++ [
|
|||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
# Run packages
|
# Run Packages
|
||||||
(buildPackages: {
|
(buildPackages: {
|
||||||
inherit system platform crossSystem config overlays;
|
inherit system platform crossSystem config overlays;
|
||||||
|
selfBuild = false;
|
||||||
stdenv = if crossSystem.useiOSCross or false
|
stdenv = if crossSystem.useiOSCross or false
|
||||||
then let
|
then let
|
||||||
inherit (buildPackages.darwin.ios-cross {
|
inherit (buildPackages.darwin.ios-cross {
|
||||||
|
@ -115,7 +115,19 @@ let
|
|||||||
, sandboxProfile ? ""
|
, sandboxProfile ? ""
|
||||||
, propagatedSandboxProfile ? ""
|
, propagatedSandboxProfile ? ""
|
||||||
, ... } @ attrs:
|
, ... } @ attrs:
|
||||||
let
|
let # Rename argumemnts to avoid cycles
|
||||||
|
buildInputs__ = buildInputs;
|
||||||
|
nativeBuildInputs__ = nativeBuildInputs;
|
||||||
|
propagatedBuildInputs__ = propagatedBuildInputs;
|
||||||
|
propagatedNativeBuildInputs__ = propagatedNativeBuildInputs;
|
||||||
|
in let
|
||||||
|
getNativeDrv = drv: drv.nativeDrv or drv;
|
||||||
|
getCrossDrv = drv: drv.crossDrv or drv;
|
||||||
|
nativeBuildInputs = map getNativeDrv nativeBuildInputs__;
|
||||||
|
buildInputs = map getCrossDrv buildInputs__;
|
||||||
|
propagatedBuildInputs = map getCrossDrv propagatedBuildInputs__;
|
||||||
|
propagatedNativeBuildInputs = map getNativeDrv propagatedNativeBuildInputs__;
|
||||||
|
in let
|
||||||
pos' =
|
pos' =
|
||||||
if pos != null then
|
if pos != null then
|
||||||
pos
|
pos
|
||||||
|
@ -55,11 +55,12 @@ let
|
|||||||
if toolsArch == "armv6l" then raspberrypiCrossSystem else
|
if toolsArch == "armv6l" then raspberrypiCrossSystem else
|
||||||
if toolsArch == "armv7l" then armv7l-hf-multiplatform-crossSystem else null;
|
if toolsArch == "armv7l" then armv7l-hf-multiplatform-crossSystem else null;
|
||||||
|
|
||||||
pkgs = pkgsFun ({inherit system;} // selectedCrossSystem);
|
pkgsUnspliced = pkgsFun ({inherit system;} // selectedCrossSystem);
|
||||||
|
pkgs = pkgsUnspliced.splicedPackages;
|
||||||
|
|
||||||
inherit (pkgs) stdenv nukeReferences cpio binutilsCross;
|
inherit (pkgsUnspliced.buildPackages) stdenv nukeReferences cpio binutilsCross;
|
||||||
|
|
||||||
glibc = pkgs.libcCross;
|
glibc = pkgs.libcCross.nativeDrv;
|
||||||
bash = pkgs.bash.crossDrv;
|
bash = pkgs.bash.crossDrv;
|
||||||
findutils = pkgs.findutils.crossDrv;
|
findutils = pkgs.findutils.crossDrv;
|
||||||
diffutils = pkgs.diffutils.crossDrv;
|
diffutils = pkgs.diffutils.crossDrv;
|
||||||
@ -71,7 +72,7 @@ let
|
|||||||
gnumake = pkgs.gnumake.crossDrv;
|
gnumake = pkgs.gnumake.crossDrv;
|
||||||
patch = pkgs.patch.crossDrv;
|
patch = pkgs.patch.crossDrv;
|
||||||
patchelf = pkgs.patchelf.crossDrv;
|
patchelf = pkgs.patchelf.crossDrv;
|
||||||
gcc = pkgs.gcc.cc.crossDrv;
|
gcc = pkgs.gcc.crossDrv.cc;
|
||||||
gmpxx = pkgs.gmpxx.crossDrv;
|
gmpxx = pkgs.gmpxx.crossDrv;
|
||||||
mpfr = pkgs.mpfr.crossDrv;
|
mpfr = pkgs.mpfr.crossDrv;
|
||||||
zlib = pkgs.zlib.crossDrv;
|
zlib = pkgs.zlib.crossDrv;
|
||||||
@ -86,17 +87,17 @@ in
|
|||||||
rec {
|
rec {
|
||||||
|
|
||||||
|
|
||||||
coreutilsMinimal = (pkgs.coreutils.override (args: {
|
coreutilsMinimal = pkgs.coreutils.override (args: {
|
||||||
# We want coreutils without ACL/attr support.
|
# We want coreutils without ACL/attr support.
|
||||||
aclSupport = false;
|
aclSupport = false;
|
||||||
attrSupport = false;
|
attrSupport = false;
|
||||||
# Our tooling currently can't handle scripts in bin/, only ELFs and symlinks.
|
# Our tooling currently can't handle scripts in bin/, only ELFs and symlinks.
|
||||||
singleBinary = "symlinks";
|
singleBinary = "symlinks";
|
||||||
})).crossDrv;
|
});
|
||||||
|
|
||||||
tarMinimal = (pkgs.gnutar.override { acl = null; }).crossDrv;
|
tarMinimal = pkgs.gnutar.override { acl = null; };
|
||||||
|
|
||||||
busyboxMinimal = (pkgs.busybox.override {
|
busyboxMinimal = pkgs.busybox.override {
|
||||||
useMusl = true;
|
useMusl = true;
|
||||||
enableStatic = true;
|
enableStatic = true;
|
||||||
enableMinimal = true;
|
enableMinimal = true;
|
||||||
@ -109,13 +110,13 @@ rec {
|
|||||||
CONFIG_TAR y
|
CONFIG_TAR y
|
||||||
CONFIG_UNXZ y
|
CONFIG_UNXZ y
|
||||||
'';
|
'';
|
||||||
}).crossDrv;
|
};
|
||||||
|
|
||||||
build =
|
build =
|
||||||
|
|
||||||
stdenv.mkDerivation {
|
stdenv.mkDerivation {
|
||||||
name = "stdenv-bootstrap-tools-cross";
|
name = "stdenv-bootstrap-tools-cross";
|
||||||
crossConfig = stdenv.cross.config;
|
crossConfig = pkgsUnspliced.crossSystem.config;
|
||||||
|
|
||||||
buildInputs = [nukeReferences cpio binutilsCross];
|
buildInputs = [nukeReferences cpio binutilsCross];
|
||||||
|
|
||||||
|
@ -10,26 +10,12 @@ self: pkgs:
|
|||||||
|
|
||||||
with pkgs;
|
with pkgs;
|
||||||
|
|
||||||
let
|
|
||||||
defaultScope = pkgs // pkgs.xorg;
|
|
||||||
in
|
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|
||||||
# Allow callPackage to fill in the pkgs argument
|
# Allow callPackage to fill in the pkgs argument
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
|
|
||||||
|
|
||||||
# We use `callPackage' to be able to omit function arguments that
|
|
||||||
# can be obtained from `pkgs' or `pkgs.xorg' (i.e. `defaultScope').
|
|
||||||
# Use `newScope' for sets of packages in `pkgs' (see e.g. `gnome'
|
|
||||||
# below).
|
|
||||||
callPackage = newScope {};
|
|
||||||
|
|
||||||
callPackages = lib.callPackagesWith defaultScope;
|
|
||||||
|
|
||||||
newScope = extra: lib.callPackageWith (defaultScope // extra);
|
|
||||||
|
|
||||||
# Override system. This is useful to build i686 packages on x86_64-linux.
|
# Override system. This is useful to build i686 packages on x86_64-linux.
|
||||||
forceSystem = system: kernel: nixpkgsFun {
|
forceSystem = system: kernel: nixpkgsFun {
|
||||||
inherit system;
|
inherit system;
|
||||||
@ -39,15 +25,9 @@ in
|
|||||||
# Used by wine, firefox with debugging version of Flash, ...
|
# Used by wine, firefox with debugging version of Flash, ...
|
||||||
pkgsi686Linux = forceSystem "i686-linux" "i386";
|
pkgsi686Linux = forceSystem "i686-linux" "i386";
|
||||||
|
|
||||||
callPackage_i686 = lib.callPackageWith (pkgsi686Linux // pkgsi686Linux.xorg);
|
callPackage_i686 = pkgsi686Linux.callPackage;
|
||||||
|
|
||||||
forceNativeDrv = drv:
|
forcedNativePackages = if crossSystem == null then pkgs else buildPackages;
|
||||||
# Even when cross compiling, some packages come from the stdenv's
|
|
||||||
# bootstrapping package set. Those packages are only built for the native
|
|
||||||
# platform.
|
|
||||||
if crossSystem != null && drv ? crossDrv
|
|
||||||
then drv // { crossDrv = drv.nativeDrv; }
|
|
||||||
else drv;
|
|
||||||
|
|
||||||
# A stdenv capable of building 32-bit binaries. On x86_64-linux,
|
# A stdenv capable of building 32-bit binaries. On x86_64-linux,
|
||||||
# it uses GCC compiled with multilib support; on i686-linux, it's
|
# it uses GCC compiled with multilib support; on i686-linux, it's
|
||||||
@ -4771,41 +4751,45 @@ in
|
|||||||
|
|
||||||
gccApple = throw "gccApple is no longer supported";
|
gccApple = throw "gccApple is no longer supported";
|
||||||
|
|
||||||
gccCrossStageStatic = let
|
gccCrossStageStatic = assert crossSystem != null; let
|
||||||
libcCross1 =
|
libcCross1 =
|
||||||
if stdenv.cross.libc == "msvcrt" then windows.mingw_w64_headers
|
if stdenv.cross.libc == "msvcrt" then windows.mingw_w64_headers
|
||||||
else if stdenv.cross.libc == "libSystem" then darwin.xcode
|
else if stdenv.cross.libc == "libSystem" then darwin.xcode
|
||||||
else null;
|
else null;
|
||||||
in wrapGCCCross {
|
in wrapGCCCross {
|
||||||
gcc = forceNativeDrv (gcc.cc.override {
|
gcc = forcedNativePackages.gcc.cc.override {
|
||||||
cross = crossSystem;
|
cross = crossSystem;
|
||||||
crossStageStatic = true;
|
crossStageStatic = true;
|
||||||
langCC = false;
|
langCC = false;
|
||||||
libcCross = libcCross1;
|
libcCross = libcCross1;
|
||||||
enableShared = false;
|
enableShared = false;
|
||||||
});
|
# Why is this needed?
|
||||||
|
inherit (forcedNativePackages) binutilsCross;
|
||||||
|
};
|
||||||
libc = libcCross1;
|
libc = libcCross1;
|
||||||
binutils = binutilsCross;
|
binutils = binutilsCross;
|
||||||
cross = crossSystem;
|
cross = crossSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
# Only needed for mingw builds
|
# Only needed for mingw builds
|
||||||
gccCrossMingw2 = wrapGCCCross {
|
gccCrossMingw2 = assert crossSystem != null; wrapGCCCross {
|
||||||
gcc = gccCrossStageStatic.gcc;
|
gcc = gccCrossStageStatic.gcc;
|
||||||
libc = windows.mingw_headers2;
|
libc = windows.mingw_headers2;
|
||||||
binutils = binutilsCross;
|
binutils = binutilsCross;
|
||||||
cross = assert crossSystem != null; crossSystem;
|
cross = assert crossSystem != null; crossSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
gccCrossStageFinal = wrapGCCCross {
|
gccCrossStageFinal = assert crossSystem != null; wrapGCCCross {
|
||||||
gcc = forceNativeDrv (gcc.cc.override {
|
gcc = forcedNativePackages.gcc.cc.override {
|
||||||
cross = crossSystem;
|
cross = crossSystem;
|
||||||
crossStageStatic = false;
|
crossStageStatic = false;
|
||||||
|
|
||||||
# XXX: We have troubles cross-compiling libstdc++ on MinGW (see
|
# XXX: We have troubles cross-compiling libstdc++ on MinGW (see
|
||||||
# <http://hydra.nixos.org/build/4268232>), so don't even try.
|
# <http://hydra.nixos.org/build/4268232>), so don't even try.
|
||||||
langCC = crossSystem.config != "i686-pc-mingw32";
|
langCC = crossSystem.config != "i686-pc-mingw32";
|
||||||
});
|
# Why is this needed?
|
||||||
|
inherit (forcedNativePackages) binutilsCross;
|
||||||
|
};
|
||||||
libc = libcCross;
|
libc = libcCross;
|
||||||
binutils = binutilsCross;
|
binutils = binutilsCross;
|
||||||
cross = crossSystem;
|
cross = crossSystem;
|
||||||
@ -5499,12 +5483,12 @@ in
|
|||||||
wrapGCCCross =
|
wrapGCCCross =
|
||||||
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
|
{gcc, libc, binutils, cross, shell ? "", name ? "gcc-cross-wrapper"}:
|
||||||
|
|
||||||
forceNativeDrv (callPackage ../build-support/gcc-cross-wrapper {
|
forcedNativePackages.callPackage ../build-support/gcc-cross-wrapper {
|
||||||
nativeTools = false;
|
nativeTools = false;
|
||||||
nativeLibc = false;
|
nativeLibc = false;
|
||||||
noLibc = (libc == null);
|
noLibc = (libc == null);
|
||||||
inherit gcc binutils libc shell name cross;
|
inherit gcc binutils libc shell name cross;
|
||||||
});
|
};
|
||||||
|
|
||||||
# prolog
|
# prolog
|
||||||
yap = callPackage ../development/compilers/yap { };
|
yap = callPackage ../development/compilers/yap { };
|
||||||
@ -6084,12 +6068,12 @@ in
|
|||||||
gold = false;
|
gold = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
binutilsCross = assert crossSystem != null; lowPrio (forceNativeDrv (
|
binutilsCross = assert crossSystem != null; lowPrio (
|
||||||
if crossSystem.libc == "libSystem" then darwin.cctools_cross
|
if crossSystem.libc == "libSystem" then darwin.cctools_cross
|
||||||
else binutils.override {
|
else forcedNativePackages.binutils.override {
|
||||||
noSysDirs = true;
|
noSysDirs = true;
|
||||||
cross = crossSystem;
|
cross = crossSystem;
|
||||||
}));
|
});
|
||||||
|
|
||||||
bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { };
|
bison2 = callPackage ../development/tools/parsing/bison/2.x.nix { };
|
||||||
bison3 = callPackage ../development/tools/parsing/bison/3.x.nix { };
|
bison3 = callPackage ../development/tools/parsing/bison/3.x.nix { };
|
||||||
@ -6558,9 +6542,9 @@ in
|
|||||||
cross_renaming: we should make all programs use pkgconfig as
|
cross_renaming: we should make all programs use pkgconfig as
|
||||||
nativeBuildInput after the renaming.
|
nativeBuildInput after the renaming.
|
||||||
*/
|
*/
|
||||||
pkgconfig = forceNativeDrv (callPackage ../development/tools/misc/pkgconfig {
|
pkgconfig = forcedNativePackages.callPackage ../development/tools/misc/pkgconfig {
|
||||||
fetchurl = fetchurlBoot;
|
fetchurl = fetchurlBoot;
|
||||||
});
|
};
|
||||||
pkgconfigUpstream = lowPrio (pkgconfig.override { vanilla = true; });
|
pkgconfigUpstream = lowPrio (pkgconfig.override { vanilla = true; });
|
||||||
|
|
||||||
postiats-utilities = callPackage ../development/tools/postiats-utilities {};
|
postiats-utilities = callPackage ../development/tools/postiats-utilities {};
|
||||||
@ -7336,10 +7320,10 @@ in
|
|||||||
withGd = true;
|
withGd = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
glibcCross = forceNativeDrv (glibc.override {
|
glibcCross = forcedNativePackages.glibc.override {
|
||||||
gccCross = gccCrossStageStatic;
|
gccCross = gccCrossStageStatic;
|
||||||
linuxHeaders = linuxHeadersCross;
|
linuxHeaders = linuxHeadersCross;
|
||||||
});
|
};
|
||||||
|
|
||||||
# We can choose:
|
# We can choose:
|
||||||
libcCrossChooser = name: if name == "glibc" then glibcCross
|
libcCrossChooser = name: if name == "glibc" then glibcCross
|
||||||
@ -10910,7 +10894,7 @@ in
|
|||||||
cmdline = callPackage ../os-specific/darwin/command-line-tools {};
|
cmdline = callPackage ../os-specific/darwin/command-line-tools {};
|
||||||
apple-source-releases = callPackage ../os-specific/darwin/apple-source-releases { };
|
apple-source-releases = callPackage ../os-specific/darwin/apple-source-releases { };
|
||||||
in apple-source-releases // rec {
|
in apple-source-releases // rec {
|
||||||
cctools_cross = callPackage (forceNativeDrv (callPackage ../os-specific/darwin/cctools/port.nix {}).cross) {
|
cctools_cross = callPackage (forcedNativePackages.callPackage ../os-specific/darwin/cctools/port.nix {}).cross {
|
||||||
cross = assert crossSystem != null; crossSystem;
|
cross = assert crossSystem != null; crossSystem;
|
||||||
inherit maloader;
|
inherit maloader;
|
||||||
xctoolchain = xcode.toolchain;
|
xctoolchain = xcode.toolchain;
|
||||||
@ -11148,13 +11132,13 @@ in
|
|||||||
|
|
||||||
linuxHeaders = linuxHeaders_4_4;
|
linuxHeaders = linuxHeaders_4_4;
|
||||||
|
|
||||||
linuxHeaders24Cross = forceNativeDrv (callPackage ../os-specific/linux/kernel-headers/2.4.nix {
|
linuxHeaders24Cross = forcedNativePackages.callPackage ../os-specific/linux/kernel-headers/2.4.nix {
|
||||||
cross = assert crossSystem != null; crossSystem;
|
cross = assert crossSystem != null; crossSystem;
|
||||||
});
|
};
|
||||||
|
|
||||||
linuxHeaders26Cross = forceNativeDrv (callPackage ../os-specific/linux/kernel-headers/4.4.nix {
|
linuxHeaders26Cross = forcedNativePackages.callPackage ../os-specific/linux/kernel-headers/4.4.nix {
|
||||||
cross = assert crossSystem != null; crossSystem;
|
cross = assert crossSystem != null; crossSystem;
|
||||||
});
|
};
|
||||||
|
|
||||||
linuxHeaders_3_18 = callPackage ../os-specific/linux/kernel-headers/3.18.nix { };
|
linuxHeaders_3_18 = callPackage ../os-specific/linux/kernel-headers/3.18.nix { };
|
||||||
|
|
||||||
|
@ -32,8 +32,10 @@ let
|
|||||||
in
|
in
|
||||||
|
|
||||||
{
|
{
|
||||||
# These `nativeDrv`s should be identical to their vanilla ones --- cross
|
# These derivations from a cross package set's `buildPackages` should be
|
||||||
# compiling should not affect the native derivation.
|
# identical to their vanilla equivalents --- none of these package should
|
||||||
|
# observe the target platform which is the only difference between those
|
||||||
|
# package sets.
|
||||||
ensureUnaffected = let
|
ensureUnaffected = let
|
||||||
# Absurd values are fine here, as we are not building anything. In fact,
|
# Absurd values are fine here, as we are not building anything. In fact,
|
||||||
# there probably a good idea to try to be "more parametric" --- i.e. avoid
|
# there probably a good idea to try to be "more parametric" --- i.e. avoid
|
||||||
@ -47,8 +49,12 @@ in
|
|||||||
# good idea lest there be some irrelevant pass-through debug attrs that
|
# good idea lest there be some irrelevant pass-through debug attrs that
|
||||||
# cause false negatives.
|
# cause false negatives.
|
||||||
testEqualOne = path: system: let
|
testEqualOne = path: system: let
|
||||||
f = attrs: builtins.toString (lib.getAttrFromPath path (allPackages attrs));
|
f = path: attrs: builtins.toString (lib.getAttrFromPath path (allPackages attrs));
|
||||||
in assert f { inherit system; } == f { inherit system crossSystem; }; true;
|
in assert
|
||||||
|
f path { inherit system; }
|
||||||
|
==
|
||||||
|
f (["buildPackages"] ++ path) { inherit system crossSystem; };
|
||||||
|
true;
|
||||||
|
|
||||||
testEqual = path: systems: forAllSupportedSystems systems (testEqualOne path);
|
testEqual = path: systems: forAllSupportedSystems systems (testEqualOne path);
|
||||||
|
|
||||||
|
@ -76,8 +76,9 @@ rec {
|
|||||||
* parameter for allPackages, defining the target platform for cross builds,
|
* parameter for allPackages, defining the target platform for cross builds,
|
||||||
* and triggering the build of the host derivation (cross built - crossDrv). */
|
* and triggering the build of the host derivation (cross built - crossDrv). */
|
||||||
mapTestOnCross = crossSystem: mapAttrsRecursive
|
mapTestOnCross = crossSystem: mapAttrsRecursive
|
||||||
(path: systems: testOnCross crossSystem systems
|
(path: systems: testOnCross crossSystem systems (pkgs: addMetaAttrs
|
||||||
(pkgs: addMetaAttrs { maintainers = crossMaintainers; } (getAttrFromPath path pkgs)));
|
{ maintainers = crossMaintainers; }
|
||||||
|
(getAttrFromPath path pkgs.splicedPackages)));
|
||||||
|
|
||||||
|
|
||||||
/* Recursively map a (nested) set of derivations to an isomorphic
|
/* Recursively map a (nested) set of derivations to an isomorphic
|
||||||
|
76
pkgs/top-level/splice.nix
Normal file
76
pkgs/top-level/splice.nix
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
# The `splicedPackages' package set, and its use by `callPackage`
|
||||||
|
#
|
||||||
|
# The `buildPackages` pkg set is a new concept, and the vast majority package
|
||||||
|
# expression (the other *.nix files) are not designed with it in mind. This
|
||||||
|
# presents us with a problem with how to get the right version (build-time vs
|
||||||
|
# run-time) of a package to a consumer that isn't used to thinking so cleverly.
|
||||||
|
#
|
||||||
|
# The solution is to splice the package sets together as we do below, so every
|
||||||
|
# `callPackage`d expression in fact gets both versions. Each# derivation (and
|
||||||
|
# each derivation's outputs) consists of the run-time version, augmented with a
|
||||||
|
# `nativeDrv` field for the build-time version, and `crossDrv` field for the
|
||||||
|
# run-time version.
|
||||||
|
#
|
||||||
|
# We could have used any names we want for the disambiguated versions, but
|
||||||
|
# `crossDrv` and `nativeDrv` were somewhat similarly used for the old
|
||||||
|
# cross-compiling infrastructure. The names are mostly invisible as
|
||||||
|
# `mkDerivation` knows how to pull out the right ones for `buildDepends` and
|
||||||
|
# friends, but a few packages use them directly, so it seemed efficient (to
|
||||||
|
# @Ericson2314) to reuse those names, at least initially, to minimize breakage.
|
||||||
|
lib: pkgs:
|
||||||
|
|
||||||
|
let
|
||||||
|
defaultBuildScope = pkgs.buildPackages // pkgs.buildPackages.xorg;
|
||||||
|
# TODO(@Ericson2314): we shouldn't preclude run-time fetching by removing
|
||||||
|
# these attributes. We should have a more general solution for selecting
|
||||||
|
# whether `nativeDrv` or `crossDrv` is the default in `defaultScope`.
|
||||||
|
pkgsWithoutFetchers = lib.filterAttrs (n: _: !lib.hasPrefix "fetch" n) pkgs;
|
||||||
|
defaultRunScope = pkgsWithoutFetchers // pkgs.xorg;
|
||||||
|
|
||||||
|
splicer = buildPkgs: runPkgs: let
|
||||||
|
mash = buildPkgs // runPkgs;
|
||||||
|
merge = name: {
|
||||||
|
inherit name;
|
||||||
|
value = let
|
||||||
|
defaultValue = mash.${name};
|
||||||
|
buildValue = buildPkgs.${name} or {};
|
||||||
|
runValue = runPkgs.${name} or {};
|
||||||
|
augmentedValue = defaultValue
|
||||||
|
// (lib.optionalAttrs (buildPkgs ? ${name}) { nativeDrv = buildValue; })
|
||||||
|
// (lib.optionalAttrs (runPkgs ? ${name}) { crossDrv = runValue; });
|
||||||
|
# Get the set of outputs of a derivation
|
||||||
|
getOutputs = value:
|
||||||
|
lib.genAttrs (value.outputs or []) (output: value.${output});
|
||||||
|
in
|
||||||
|
# Certain *Cross derivations will fail assertions, but we need their
|
||||||
|
# nativeDrv. We are assuming anything that fails to evaluate is an
|
||||||
|
# attrset (including derivation) and thus can be unioned.
|
||||||
|
if !(builtins.tryEval defaultValue).success then augmentedValue
|
||||||
|
# The derivation along with its outputs, which we recur
|
||||||
|
# on to splice them together.
|
||||||
|
else if lib.isDerivation defaultValue then augmentedValue
|
||||||
|
// splicer (getOutputs buildValue) (getOutputs runValue)
|
||||||
|
# Just recur on plain attrsets
|
||||||
|
else if lib.isAttrs defaultValue then splicer buildValue runValue
|
||||||
|
# Don't be fancy about non-derivations. But we could have used used
|
||||||
|
# `__functor__` for functions instead.
|
||||||
|
else defaultValue;
|
||||||
|
};
|
||||||
|
in lib.listToAttrs (map merge (lib.attrNames mash));
|
||||||
|
|
||||||
|
splicedPackages = splicer defaultBuildScope defaultRunScope;
|
||||||
|
|
||||||
|
in
|
||||||
|
|
||||||
|
{
|
||||||
|
splicedPackages = splicedPackages // { recurseForDerivations = false; };
|
||||||
|
|
||||||
|
# We use `callPackage' to be able to omit function arguments that can be
|
||||||
|
# obtained `pkgs` or `buildPackages` and their `xorg` package sets. Use
|
||||||
|
# `newScope' for sets of packages in `pkgs' (see e.g. `gnome' below).
|
||||||
|
callPackage = pkgs.newScope {};
|
||||||
|
|
||||||
|
callPackages = lib.callPackagesWith splicedPackages;
|
||||||
|
|
||||||
|
newScope = extra: lib.callPackageWith (splicedPackages // extra);
|
||||||
|
}
|
@ -12,6 +12,9 @@
|
|||||||
{ # The system (e.g., `i686-linux') for which to build the packages.
|
{ # The system (e.g., `i686-linux') for which to build the packages.
|
||||||
system
|
system
|
||||||
|
|
||||||
|
, # the package set used at build-time
|
||||||
|
buildPackages
|
||||||
|
|
||||||
, # The standard environment to use for building packages.
|
, # The standard environment to use for building packages.
|
||||||
stdenv
|
stdenv
|
||||||
|
|
||||||
@ -51,10 +54,13 @@ let
|
|||||||
|
|
||||||
stdenvBootstappingAndPlatforms = self: super: {
|
stdenvBootstappingAndPlatforms = self: super: {
|
||||||
stdenv = stdenv // { inherit platform; };
|
stdenv = stdenv // { inherit platform; };
|
||||||
|
buildPackages = buildPackages // { recurseForDerivations = false; };
|
||||||
inherit
|
inherit
|
||||||
system platform crossSystem;
|
system platform crossSystem;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
splice = self: super: import ./splice.nix lib self;
|
||||||
|
|
||||||
allPackages = self: super:
|
allPackages = self: super:
|
||||||
let res = import ./all-packages.nix
|
let res = import ./all-packages.nix
|
||||||
{ inherit lib nixpkgsFun noSysDirs config; }
|
{ inherit lib nixpkgsFun noSysDirs config; }
|
||||||
@ -85,6 +91,7 @@ let
|
|||||||
stdenvBootstappingAndPlatforms
|
stdenvBootstappingAndPlatforms
|
||||||
stdenvAdapters
|
stdenvAdapters
|
||||||
trivialBuilders
|
trivialBuilders
|
||||||
|
splice
|
||||||
allPackages
|
allPackages
|
||||||
aliases
|
aliases
|
||||||
stdenvOverrides
|
stdenvOverrides
|
||||||
|
Loading…
Reference in New Issue
Block a user