release-lib: Simplify

This commit is contained in:
Eelco Dolstra 2015-03-20 18:16:43 +01:00
parent 6938090725
commit 738cf42639
3 changed files with 24 additions and 56 deletions

View file

@ -38,18 +38,13 @@ rec {
crossMaintainers = [ maintainers.viric ]; crossMaintainers = [ maintainers.viric ];
toJob = x: if isAttrs x then x else
{ type = "job"; systems = x; };
/* Build a package on the given set of platforms. The function `f' /* Build a package on the given set of platforms. The function `f'
is called for each supported platform with Nixpkgs for that is called for each supported platform with Nixpkgs for that
platform as an argument . We return an attribute set containing platform as an argument . We return an attribute set containing
a derivation for each supported platform, i.e. { x86_64-linux = a derivation for each supported platform, i.e. { x86_64-linux =
f pkgs_x86_64_linux; i686-linux = f pkgs_i686_linux; ... }. */ f pkgs_x86_64_linux; i686-linux = f pkgs_i686_linux; ... }. */
testOn = systems: f: genAttrs testOn = systems: f: genAttrs
(filter (x: elem x supportedSystems) systems) (filter (x: elem x supportedSystems) systems) (system: f (pkgsFor system));
(system: f (pkgsFor system));
/* Similar to the testOn function, but with an additional /* Similar to the testOn function, but with an additional
@ -61,60 +56,33 @@ rec {
else {}; else {};
/* Map an attribute of the form `foo = [platforms...]' to `testOn /* Given a nested set where the leaf nodes are lists of platforms,
[platforms...] (pkgs: pkgs.foo)'. */ map each leaf node to `testOn [platforms...] (pkgs:
mapTestOn = mapAttrsRecursiveCond pkgs.<attrPath>)'. */
(as: as.type or "" != "job") mapTestOn = mapAttrsRecursive
(path: value: (path: systems: testOn systems (pkgs: getAttrFromPath path pkgs));
let
job = toJob value;
getPkg = pkgs: getAttrFromPath path pkgs;
in testOn job.systems getPkg);
/* Similar to the testOn function, but with an additional 'crossSystem' /* Similar to the testOn function, but with an additional 'crossSystem'
* 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: mapAttrsRecursiveCond mapTestOnCross = crossSystem: mapAttrsRecursive
(as: as.type or "" != "job") (path: systems: testOnCross crossSystem systems
(path: value: (pkgs: addMetaAttrs { maintainers = crossMaintainers; } (getAttrFromPath path pkgs)));
let
job = toJob value;
getPkg = pkgs: addMetaAttrs { maintainers = crossMaintainers; }
(getAttrFromPath path pkgs);
in testOnCross crossSystem job.systems getPkg);
/* Find all packages that have a meta.platforms field listing the /* Recursively map a (nested) set of derivations to an isomorphic
supported platforms. */ set of meta.platforms values. */
packagesWithMetaPlatform = attrSet: packagePlatforms = mapAttrs (name: value:
let pairs = concatMap let res = builtins.tryEval (
(x: if isDerivation value then
let pair = builtins.tryEval value.meta.hydraPlatforms or (value.meta.platforms or [])
(let else if value.recurseForDerivations or false || value.recurseForRelease or false then
attrVal = attrSet.${x}; packagePlatforms value
in else
{ val = processPackage attrVal; []);
attrVal = attrVal; in if res.success then res.value else []
attrValIsAttrs = isAttrs attrVal; );
});
success = (builtins.tryEval pair.value.attrVal).success;
in
optional (success && pair.value.attrValIsAttrs && pair.value.val != [])
{ name = x; value = pair.value.val; })
(attrNames attrSet);
in
listToAttrs pairs;
# May fail as much as it wishes, we will catch the error.
processPackage = attrSet:
if attrSet.recurseForDerivations or false || attrSet.recurseForRelease or false then
packagesWithMetaPlatform attrSet
else if attrSet.meta.broken or false then
[]
else
attrSet.meta.hydraPlatforms or (attrSet.meta.platforms or []);
/* Common platform groups on which to test packages. */ /* Common platform groups on which to test packages. */

View file

@ -153,7 +153,7 @@ with import ./release-lib.nix { inherit supportedSystems; };
sqlite = allBut cygwin; sqlite = allBut cygwin;
squid = linux; squid = linux;
ssmtp = linux; ssmtp = linux;
stdenv = prio 175 all; stdenv = all;
strace = linux; strace = linux;
su = linux; su = linux;
sudo = linux; sudo = linux;

View file

@ -47,7 +47,7 @@ let
]; ];
}; };
} // (mapTestOn ((packagesWithMetaPlatform pkgs) // rec { } // (mapTestOn ((packagePlatforms pkgs) // rec {
abcde = linux; abcde = linux;
apacheHttpd = linux; apacheHttpd = linux;
@ -270,7 +270,7 @@ let
gnome_vfs = linux; gnome_vfs = linux;
}; };
haskell-ng.compiler = packagesWithMetaPlatform pkgs.haskell-ng.compiler; haskell-ng.compiler = packagePlatforms pkgs.haskell-ng.compiler;
strategoPackages = { strategoPackages = {
sdf = linux; sdf = linux;