release-lib.nix: Style cleanup

This commit is contained in:
Eelco Dolstra 2015-03-20 17:05:30 +01:00
parent ef0e4d56f5
commit b981eb3f7b

View file

@ -1,5 +1,7 @@
{ supportedSystems, packageSet ? (import ./all-packages.nix) }:
with import ../../lib;
rec {
# Ensure that we don't build packages marked as unfree.
@ -7,7 +9,7 @@ rec {
config.allowUnfree = false;
});
pkgs = allPackages { system = "x86_64-linux"; };
pkgs = pkgsFor "x86_64-linux";
/* !!! Hack: poor man's memoisation function. Necessary to prevent
@ -33,10 +35,10 @@ rec {
/* 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. */
crossMaintainers = with pkgs.lib.maintainers; [ viric ];
crossMaintainers = [ maintainers.viric ];
toJob = x: if builtins.isAttrs x then x else
toJob = x: if isAttrs x then x else
{ type = "job"; systems = x; };
@ -45,8 +47,8 @@ rec {
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: pkgs.lib.genAttrs
(pkgs.lib.filter (x: pkgs.lib.elem x supportedSystems) systems)
testOn = systems: f: genAttrs
(filter (x: elem x supportedSystems) systems)
(system: f (pkgsFor system));
@ -54,62 +56,60 @@ rec {
'crossSystem' parameter for allPackages, defining the target
platform for cross builds. */
testOnCross = crossSystem: systems: f: {system ? builtins.currentSystem}:
if pkgs.lib.elem system systems
if elem system systems
then f (allPackages { inherit system crossSystem; })
else {};
/* Map an attribute of the form `foo = [platforms...]' to `testOn
[platforms...] (pkgs: pkgs.foo)'. */
mapTestOn = pkgs.lib.mapAttrsRecursiveCond
mapTestOn = mapAttrsRecursiveCond
(as: as.type or "" != "job")
(path: value:
let
job = toJob value;
getPkg = pkgs: pkgs.lib.getAttrFromPath path pkgs;
getPkg = pkgs: getAttrFromPath path pkgs;
in testOn job.systems getPkg);
/* 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). */
mapTestOnCross = crossSystem: pkgs.lib.mapAttrsRecursiveCond
mapTestOnCross = crossSystem: mapAttrsRecursiveCond
(as: as.type or "" != "job")
(path: value:
let
job = toJob value;
getPkg = pkgs: pkgs.lib.addMetaAttrs { maintainers = crossMaintainers; }
(pkgs.lib.getAttrFromPath path pkgs);
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
supported platforms. */
packagesWithMetaPlatform = attrSet:
let pairs = pkgs.lib.concatMap
let pairs = concatMap
(x:
let pair = builtins.tryEval
(let
attrVal = (builtins.getAttr x attrSet);
attrVal = attrSet.${x};
in
{ val = processPackage attrVal;
attrVal = attrVal;
attrValIsAttrs = builtins.isAttrs attrVal;
attrValIsAttrs = isAttrs attrVal;
});
success = (builtins.tryEval pair.value.attrVal).success;
in
pkgs.lib.optional (success && pair.value.attrValIsAttrs && pair.value.val != [])
optional (success && pair.value.attrValIsAttrs && pair.value.val != [])
{ name = x; value = pair.value.val; })
(builtins.attrNames attrSet);
(attrNames attrSet);
in
builtins.listToAttrs pairs;
listToAttrs pairs;
# May fail as much as it wishes, we will catch the error.
processPackage = attrSet:
if attrSet.recurseForDerivations or false then
packagesWithMetaPlatform attrSet
else if attrSet.recurseForRelease or false then
if attrSet.recurseForDerivations or false || attrSet.recurseForRelease or false then
packagesWithMetaPlatform attrSet
else if attrSet.meta.broken or false then
[]
@ -118,7 +118,7 @@ rec {
/* Common platform groups on which to test packages. */
inherit (pkgs.lib.platforms) unix linux darwin cygwin allBut all mesaPlatforms;
inherit (platforms) unix linux darwin cygwin allBut all mesaPlatforms;
/* Platform groups for specific kinds of applications. */
x11Supported = linux;