mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-26 21:33:03 +03:00
release-lib: Filter supportedSystems with meta.platforms
-style patterns
Instead of intersecting system strings, we filter with the sort of patterns used in `meta.platforms`. Indicating this change `forTheseSystems` has been renamed to `forMatchingSystems`, since the given list is now patterns to match, and not the systems themselves. [Just as with `meta.platforms`, systems strings are also supported for backwards compatibility.] This is more flexible, and makes the `forMatchingSystems` and packagePlatforms` cases more analogous.
This commit is contained in:
parent
e547bd0dc4
commit
192f4144b2
@ -16,7 +16,7 @@ let
|
||||
inherit system;
|
||||
} // args);
|
||||
|
||||
callTestOnTheseSystems = systems: fn: args: forTheseSystems systems (system: hydraJob (importTest fn args system));
|
||||
callTestOnTheseSystems = systems: fn: args: forMatchingSystems systems (system: hydraJob (importTest fn args system));
|
||||
callTest = callTestOnTheseSystems supportedSystems;
|
||||
|
||||
callSubTests = callSubTestsOnTheseSystems supportedSystems;
|
||||
@ -123,7 +123,7 @@ in rec {
|
||||
# Build the initial ramdisk so Hydra can keep track of its size over time.
|
||||
initialRamdisk = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.initialRamdisk);
|
||||
|
||||
netboot = forTheseSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
|
||||
netboot = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
|
||||
inherit system;
|
||||
modules = [
|
||||
./modules/installer/netboot/netboot-minimal.nix
|
||||
@ -137,7 +137,7 @@ in rec {
|
||||
inherit system;
|
||||
});
|
||||
|
||||
iso_graphical = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
|
||||
iso_graphical = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
|
||||
module = ./modules/installer/cd-dvd/installation-cd-graphical-kde.nix;
|
||||
type = "graphical";
|
||||
inherit system;
|
||||
@ -145,7 +145,7 @@ in rec {
|
||||
|
||||
# A variant with a more recent (but possibly less stable) kernel
|
||||
# that might support more hardware.
|
||||
iso_minimal_new_kernel = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
|
||||
iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
|
||||
module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
|
||||
type = "minimal-new-kernel";
|
||||
inherit system;
|
||||
@ -153,7 +153,7 @@ in rec {
|
||||
|
||||
|
||||
# A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
|
||||
ova = forTheseSystems [ "x86_64-linux" ] (system:
|
||||
ova = forMatchingSystems [ "x86_64-linux" ] (system:
|
||||
|
||||
with import nixpkgs { inherit system; };
|
||||
|
||||
|
@ -88,7 +88,7 @@ in
|
||||
f (["buildPackages"] ++ path) { inherit system crossSystem; }
|
||||
);
|
||||
|
||||
testEqual = path: systems: forTheseSystems systems (testEqualOne path);
|
||||
testEqual = path: systems: forMatchingSystems systems (testEqualOne path);
|
||||
|
||||
mapTestEqual = lib.mapAttrsRecursive testEqual;
|
||||
|
||||
|
@ -48,33 +48,56 @@ rec {
|
||||
pkgs_x86_64_cygwin = allPackages { system = "x86_64-cygwin"; };
|
||||
|
||||
|
||||
# Given a list of 'meta.platforms'-style patterns, return the sublist of
|
||||
# `supportedSystems` containing systems that matches at least one of the given
|
||||
# patterns.
|
||||
#
|
||||
# This is written in a funny way so that we only elaborate the systems once.
|
||||
supportedMatches = let
|
||||
supportedPlatforms = map
|
||||
(system: lib.systems.elaborate { inherit system; })
|
||||
supportedSystems;
|
||||
in metaPatterns: let
|
||||
anyMatch = platform:
|
||||
lib.any (lib.meta.platformMatch platform) metaPatterns;
|
||||
matchingPlatforms = lib.filter anyMatch supportedPlatforms;
|
||||
in map ({ system, ...}: system) matchingPlatforms;
|
||||
|
||||
|
||||
assertTrue = bool:
|
||||
if bool
|
||||
then pkgs.runCommand "evaluated-to-true" {} "touch $out"
|
||||
else pkgs.runCommand "evaluated-to-false" {} "false";
|
||||
|
||||
|
||||
/* 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 = [ maintainers.viric ];
|
||||
|
||||
|
||||
# Generate attributes for all supported systems.
|
||||
forAllSystems = genAttrs supportedSystems;
|
||||
forTheseSystems = systems: f:
|
||||
genAttrs (filter (x: elem x supportedSystems) systems) f;
|
||||
|
||||
|
||||
# Generate attributes for all sytems matching at least one of the given
|
||||
# patterns
|
||||
forMatchingSystems = metaPatterns: genAttrs (supportedMatches metaPatterns);
|
||||
|
||||
|
||||
/* 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: forTheseSystems systems
|
||||
testOn = metaPatterns: f: forMatchingSystems metaPatterns
|
||||
(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: forTheseSystems systems
|
||||
testOnCross = crossSystem: metaPatterns: f: forMatchingSystems metaPatterns
|
||||
(system: hydraJob' (f (allPackages { inherit system crossSystem; })));
|
||||
|
||||
|
||||
@ -82,14 +105,14 @@ rec {
|
||||
map each leaf node to `testOn [platforms...] (pkgs:
|
||||
pkgs.<attrPath>)'. */
|
||||
mapTestOn = mapAttrsRecursive
|
||||
(path: systems: testOn systems (pkgs: getAttrFromPath path pkgs));
|
||||
(path: metaPatterns: testOn metaPatterns (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). */
|
||||
mapTestOnCross = crossSystem: mapAttrsRecursive
|
||||
(path: systems: testOnCross crossSystem systems
|
||||
(path: metaPatterns: testOnCross crossSystem metaPatterns
|
||||
(pkgs: addMetaAttrs { maintainers = crossMaintainers; } (getAttrFromPath path pkgs)));
|
||||
|
||||
|
||||
@ -98,12 +121,8 @@ rec {
|
||||
packagePlatforms = mapAttrs (name: value:
|
||||
let res = builtins.tryEval (
|
||||
if isDerivation value then
|
||||
value.meta.hydraPlatforms or (let
|
||||
linuxDefaulted = value.meta.platforms or [ "x86_64-linux" ];
|
||||
pred = system: lib.any
|
||||
(lib.meta.platformMatch (lib.systems.elaborate { inherit system; }))
|
||||
linuxDefaulted;
|
||||
in lib.filter pred supportedSystems)
|
||||
value.meta.hydraPlatforms
|
||||
or supportedMatches (value.meta.platforms or [ "x86_64-linux" ])
|
||||
else if value.recurseForDerivations or false || value.recurseForRelease or false then
|
||||
packagePlatforms value
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user