1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-09-11 15:08:33 +01:00
nixpkgs/pkgs/top-level/release-lib.nix

107 lines
4 KiB
Nix
Raw Normal View History

{ supportedSystems
, packageSet ? (import ../..)
, scrubJobs ? true
}:
2015-03-20 16:05:30 +00:00
with import ../../lib;
rec {
# Ensure that we don't build packages marked as unfree.
allPackages = args: packageSet (args // {
config.allowUnfree = false;
config.inHydra = true;
});
2015-03-20 16:05:30 +00:00
pkgs = pkgsFor "x86_64-linux";
hydraJob' = if scrubJobs then hydraJob else id;
/* !!! Hack: poor man's memoisation function. Necessary to prevent
Nixpkgs from being evaluated again and again for every
job/platform pair. */
pkgsFor = system:
if system == "x86_64-linux" then pkgs_x86_64_linux
else if system == "i686-linux" then pkgs_i686_linux
else if system == "x86_64-darwin" then pkgs_x86_64_darwin
else if system == "x86_64-freebsd" then pkgs_x86_64_freebsd
else if system == "i686-freebsd" then pkgs_i686_freebsd
else if system == "i686-cygwin" then pkgs_i686_cygwin
2015-05-26 14:18:49 +01:00
else if system == "x86_64-cygwin" then pkgs_x86_64_cygwin
else abort "unsupported system type: ${system}";
pkgs_x86_64_linux = allPackages { system = "x86_64-linux"; };
pkgs_i686_linux = allPackages { system = "i686-linux"; };
pkgs_x86_64_darwin = allPackages { system = "x86_64-darwin"; };
pkgs_x86_64_freebsd = allPackages { system = "x86_64-freebsd"; };
pkgs_i686_freebsd = allPackages { system = "i686-freebsd"; };
pkgs_i686_cygwin = allPackages { system = "i686-cygwin"; };
2015-05-26 14:18:49 +01:00
pkgs_x86_64_cygwin = allPackages { system = "x86_64-cygwin"; };
/* The working or failing mails for cross builds will be sent only to
the following maintainers, as most package maintainers will not be
interested in the result of cross building a package. */
2015-03-20 16:05:30 +00:00
crossMaintainers = [ maintainers.viric ];
forAllSupportedSystems = systems: f:
genAttrs (filter (x: elem x supportedSystems) systems) f;
/* Build a package on the given set of platforms. The function `f'
is called for each supported platform with Nixpkgs for that
platform as an argument . We return an attribute set containing
a derivation for each supported platform, i.e. { x86_64-linux =
f pkgs_x86_64_linux; i686-linux = f pkgs_i686_linux; ... }. */
testOn = systems: f: forAllSupportedSystems systems
(system: hydraJob' (f (pkgsFor system)));
/* Similar to the testOn function, but with an additional
'crossSystem' parameter for allPackages, defining the target
platform for cross builds. */
testOnCross = crossSystem: systems: f: forAllSupportedSystems systems
(system: hydraJob' (f (allPackages { inherit system crossSystem; })));
2015-03-20 17:16:43 +00:00
/* Given a nested set where the leaf nodes are lists of platforms,
map each leaf node to `testOn [platforms...] (pkgs:
pkgs.<attrPath>)'. */
mapTestOn = mapAttrsRecursive
(path: systems: testOn systems (pkgs: getAttrFromPath path pkgs));
/* Similar to the testOn function, but with an additional 'crossSystem'
* parameter for allPackages, defining the target platform for cross builds,
* and triggering the build of the host derivation (cross built - crossDrv). */
2015-03-20 17:16:43 +00:00
mapTestOnCross = crossSystem: mapAttrsRecursive
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
2016-12-18 07:51:18 +00:00
(path: systems: testOnCross crossSystem systems (pkgs: addMetaAttrs
{ maintainers = crossMaintainers; }
(getAttrFromPath path pkgs.splicedPackages)));
2015-03-20 17:16:43 +00:00
/* Recursively map a (nested) set of derivations to an isomorphic
set of meta.platforms values. */
packagePlatforms = mapAttrs (name: value:
let res = builtins.tryEval (
if isDerivation value then
value.meta.hydraPlatforms or (value.meta.platforms or [ "x86_64-linux" ])
2015-03-20 17:16:43 +00:00
else if value.recurseForDerivations or false || value.recurseForRelease or false then
packagePlatforms value
else
[]);
in if res.success then res.value else []
);
/* Common platform groups on which to test packages. */
2015-03-20 16:05:30 +00:00
inherit (platforms) unix linux darwin cygwin allBut all mesaPlatforms;
/* Platform groups for specific kinds of applications. */
x11Supported = linux;
gtkSupported = linux;
ghcSupported = linux;
}