release-lib.nix: Style cleanup
This commit is contained in:
parent
ef0e4d56f5
commit
b981eb3f7b
@ -1,5 +1,7 @@
|
|||||||
{ supportedSystems, packageSet ? (import ./all-packages.nix) }:
|
{ supportedSystems, packageSet ? (import ./all-packages.nix) }:
|
||||||
|
|
||||||
|
with import ../../lib;
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
|
||||||
# Ensure that we don't build packages marked as unfree.
|
# Ensure that we don't build packages marked as unfree.
|
||||||
@ -7,7 +9,7 @@ rec {
|
|||||||
config.allowUnfree = false;
|
config.allowUnfree = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
pkgs = allPackages { system = "x86_64-linux"; };
|
pkgs = pkgsFor "x86_64-linux";
|
||||||
|
|
||||||
|
|
||||||
/* !!! Hack: poor man's memoisation function. Necessary to prevent
|
/* !!! 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 working or failing mails for cross builds will be sent only to
|
||||||
the following maintainers, as most package maintainers will not be
|
the following maintainers, as most package maintainers will not be
|
||||||
interested in the result of cross building a package. */
|
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; };
|
{ type = "job"; systems = x; };
|
||||||
|
|
||||||
|
|
||||||
@ -45,8 +47,8 @@ rec {
|
|||||||
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: pkgs.lib.genAttrs
|
testOn = systems: f: genAttrs
|
||||||
(pkgs.lib.filter (x: pkgs.lib.elem x supportedSystems) systems)
|
(filter (x: elem x supportedSystems) systems)
|
||||||
(system: f (pkgsFor system));
|
(system: f (pkgsFor system));
|
||||||
|
|
||||||
|
|
||||||
@ -54,62 +56,60 @@ rec {
|
|||||||
'crossSystem' parameter for allPackages, defining the target
|
'crossSystem' parameter for allPackages, defining the target
|
||||||
platform for cross builds. */
|
platform for cross builds. */
|
||||||
testOnCross = crossSystem: systems: f: {system ? builtins.currentSystem}:
|
testOnCross = crossSystem: systems: f: {system ? builtins.currentSystem}:
|
||||||
if pkgs.lib.elem system systems
|
if elem system systems
|
||||||
then f (allPackages { inherit system crossSystem; })
|
then f (allPackages { inherit system crossSystem; })
|
||||||
else {};
|
else {};
|
||||||
|
|
||||||
|
|
||||||
/* Map an attribute of the form `foo = [platforms...]' to `testOn
|
/* Map an attribute of the form `foo = [platforms...]' to `testOn
|
||||||
[platforms...] (pkgs: pkgs.foo)'. */
|
[platforms...] (pkgs: pkgs.foo)'. */
|
||||||
mapTestOn = pkgs.lib.mapAttrsRecursiveCond
|
mapTestOn = mapAttrsRecursiveCond
|
||||||
(as: as.type or "" != "job")
|
(as: as.type or "" != "job")
|
||||||
(path: value:
|
(path: value:
|
||||||
let
|
let
|
||||||
job = toJob value;
|
job = toJob value;
|
||||||
getPkg = pkgs: pkgs.lib.getAttrFromPath path pkgs;
|
getPkg = pkgs: getAttrFromPath path pkgs;
|
||||||
in testOn job.systems getPkg);
|
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: pkgs.lib.mapAttrsRecursiveCond
|
mapTestOnCross = crossSystem: mapAttrsRecursiveCond
|
||||||
(as: as.type or "" != "job")
|
(as: as.type or "" != "job")
|
||||||
(path: value:
|
(path: value:
|
||||||
let
|
let
|
||||||
job = toJob value;
|
job = toJob value;
|
||||||
getPkg = pkgs: pkgs.lib.addMetaAttrs { maintainers = crossMaintainers; }
|
getPkg = pkgs: addMetaAttrs { maintainers = crossMaintainers; }
|
||||||
(pkgs.lib.getAttrFromPath path pkgs);
|
(getAttrFromPath path pkgs);
|
||||||
in testOnCross crossSystem job.systems getPkg);
|
in testOnCross crossSystem job.systems getPkg);
|
||||||
|
|
||||||
|
|
||||||
/* Find all packages that have a meta.platforms field listing the
|
/* Find all packages that have a meta.platforms field listing the
|
||||||
supported platforms. */
|
supported platforms. */
|
||||||
packagesWithMetaPlatform = attrSet:
|
packagesWithMetaPlatform = attrSet:
|
||||||
let pairs = pkgs.lib.concatMap
|
let pairs = concatMap
|
||||||
(x:
|
(x:
|
||||||
let pair = builtins.tryEval
|
let pair = builtins.tryEval
|
||||||
(let
|
(let
|
||||||
attrVal = (builtins.getAttr x attrSet);
|
attrVal = attrSet.${x};
|
||||||
in
|
in
|
||||||
{ val = processPackage attrVal;
|
{ val = processPackage attrVal;
|
||||||
attrVal = attrVal;
|
attrVal = attrVal;
|
||||||
attrValIsAttrs = builtins.isAttrs attrVal;
|
attrValIsAttrs = isAttrs attrVal;
|
||||||
});
|
});
|
||||||
success = (builtins.tryEval pair.value.attrVal).success;
|
success = (builtins.tryEval pair.value.attrVal).success;
|
||||||
in
|
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; })
|
{ name = x; value = pair.value.val; })
|
||||||
(builtins.attrNames attrSet);
|
(attrNames attrSet);
|
||||||
in
|
in
|
||||||
builtins.listToAttrs pairs;
|
listToAttrs pairs;
|
||||||
|
|
||||||
|
|
||||||
# May fail as much as it wishes, we will catch the error.
|
# May fail as much as it wishes, we will catch the error.
|
||||||
processPackage = attrSet:
|
processPackage = attrSet:
|
||||||
if attrSet.recurseForDerivations or false then
|
if attrSet.recurseForDerivations or false || attrSet.recurseForRelease or false then
|
||||||
packagesWithMetaPlatform attrSet
|
|
||||||
else if attrSet.recurseForRelease or false then
|
|
||||||
packagesWithMetaPlatform attrSet
|
packagesWithMetaPlatform attrSet
|
||||||
else if attrSet.meta.broken or false then
|
else if attrSet.meta.broken or false then
|
||||||
[]
|
[]
|
||||||
@ -118,7 +118,7 @@ rec {
|
|||||||
|
|
||||||
|
|
||||||
/* Common platform groups on which to test packages. */
|
/* 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. */
|
/* Platform groups for specific kinds of applications. */
|
||||||
x11Supported = linux;
|
x11Supported = linux;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user