git.iko.soy/typeable/nixpkgs
on master help sign in
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.

commit192f4144b282a7f04695fcb79d84e8278ee6af8c authorJohn Ericson <John.Ericson@Obsidian.Systems> dateMon 19 Mar 2018, 21:29 (9 years ago) parente547bd0
3 files changed+37−18
nixos/release.nix+5−5 pkgs/top-level/release-cross.nix+1−1 pkgs/top-level/release-lib.nix+31−12
nixos/release.nix+5−5
@@ -16,7 +16,7 @@ let
1616 inherit system;
1717 } // args);
1818
19− callTestOnTheseSystems = systems: fn: args: forTheseSystems systems (system: hydraJob (importTest fn args system));
19+ callTestOnTheseSystems = systems: fn: args: forMatchingSystems systems (system: hydraJob (importTest fn args system));
2020 callTest = callTestOnTheseSystems supportedSystems;
2121
2222 callSubTests = callSubTestsOnTheseSystems supportedSystems;
@@ -123,7 +123,7 @@ in rec {
123123 # Build the initial ramdisk so Hydra can keep track of its size over time.
124124 initialRamdisk = buildFromConfig ({ pkgs, ... }: { }) (config: config.system.build.initialRamdisk);
125125
126− netboot = forTheseSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
126+ netboot = forMatchingSystems [ "x86_64-linux" "aarch64-linux" ] (system: makeNetboot {
127127 inherit system;
128128 modules = [
129129 ./modules/installer/netboot/netboot-minimal.nix
@@ -137,7 +137,7 @@ in rec {
137137 inherit system;
138138 });
139139
140− iso_graphical = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
140+ iso_graphical = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
141141 module = ./modules/installer/cd-dvd/installation-cd-graphical-kde.nix;
142142 type = "graphical";
143143 inherit system;
@@ -145,7 +145,7 @@ in rec {
145145
146146 # A variant with a more recent (but possibly less stable) kernel
147147 # that might support more hardware.
148− iso_minimal_new_kernel = forTheseSystems [ "x86_64-linux" ] (system: makeIso {
148+ iso_minimal_new_kernel = forMatchingSystems [ "x86_64-linux" ] (system: makeIso {
149149 module = ./modules/installer/cd-dvd/installation-cd-minimal-new-kernel.nix;
150150 type = "minimal-new-kernel";
151151 inherit system;
@@ -153,7 +153,7 @@ in rec {
153153
154154
155155 # A bootable VirtualBox virtual appliance as an OVA file (i.e. packaged OVF).
156− ova = forTheseSystems [ "x86_64-linux" ] (system:
156+ ova = forMatchingSystems [ "x86_64-linux" ] (system:
157157
158158 with import nixpkgs { inherit system; };
159159
pkgs/top-level/release-cross.nix+1−1
@@ -88,7 +88,7 @@ in
8888 f (["buildPackages"] ++ path) { inherit system crossSystem; }
8989 );
9090
91− testEqual = path: systems: forTheseSystems systems (testEqualOne path);
91+ testEqual = path: systems: forMatchingSystems systems (testEqualOne path);
9292
9393 mapTestEqual = lib.mapAttrsRecursive testEqual;
9494
pkgs/top-level/release-lib.nix+31−12
@@ -48,33 +48,56 @@ rec {
4848 pkgs_x86_64_cygwin = allPackages { system = "x86_64-cygwin"; };
4949
5050
51+ # Given a list of 'meta.platforms'-style patterns, return the sublist of
52+ # `supportedSystems` containing systems that matches at least one of the given
53+ # patterns.
54+ #
55+ # This is written in a funny way so that we only elaborate the systems once.
56+ supportedMatches = let
57+ supportedPlatforms = map
58+ (system: lib.systems.elaborate { inherit system; })
59+ supportedSystems;
60+ in metaPatterns: let
61+ anyMatch = platform:
62+ lib.any (lib.meta.platformMatch platform) metaPatterns;
63+ matchingPlatforms = lib.filter anyMatch supportedPlatforms;
64+ in map ({ system, ...}: system) matchingPlatforms;
65+
66+
5167 assertTrue = bool:
5268 if bool
5369 then pkgs.runCommand "evaluated-to-true" {} "touch $out"
5470 else pkgs.runCommand "evaluated-to-false" {} "false";
5571
72+
5673 /* The working or failing mails for cross builds will be sent only to
5774 the following maintainers, as most package maintainers will not be
5875 interested in the result of cross building a package. */
5976 crossMaintainers = [ maintainers.viric ];
6077
78+
79+ # Generate attributes for all supported systems.
6180 forAllSystems = genAttrs supportedSystems;
62− forTheseSystems = systems: f:
63− genAttrs (filter (x: elem x supportedSystems) systems) f;
81+
82+
83+ # Generate attributes for all sytems matching at least one of the given
84+ # patterns
85+ forMatchingSystems = metaPatterns: genAttrs (supportedMatches metaPatterns);
86+
6487
6588 /* Build a package on the given set of platforms. The function `f'
6689 is called for each supported platform with Nixpkgs for that
6790 platform as an argument . We return an attribute set containing
6891 a derivation for each supported platform, i.e. ‘{ x86_64-linux =
6992 f pkgs_x86_64_linux; i686-linux = f pkgs_i686_linux; ... }’. */
70− testOn = systems: f: forTheseSystems systems
93+ testOn = metaPatterns: f: forMatchingSystems metaPatterns
7194 (system: hydraJob' (f (pkgsFor system)));
7295
7396
7497 /* Similar to the testOn function, but with an additional
7598 'crossSystem' parameter for allPackages, defining the target
7699 platform for cross builds. */
77− testOnCross = crossSystem: systems: f: forTheseSystems systems
100+ testOnCross = crossSystem: metaPatterns: f: forMatchingSystems metaPatterns
78101 (system: hydraJob' (f (allPackages { inherit system crossSystem; })));
79102
80103
@@ -82,14 +105,14 @@ rec {
82105 map each leaf node to `testOn [platforms...] (pkgs:
83106 pkgs.<attrPath>)'. */
84107 mapTestOn = mapAttrsRecursive
85− (path: systems: testOn systems (pkgs: getAttrFromPath path pkgs));
108+ (path: metaPatterns: testOn metaPatterns (pkgs: getAttrFromPath path pkgs));
86109
87110
88111 /* Similar to the testOn function, but with an additional 'crossSystem'
89112 * parameter for allPackages, defining the target platform for cross builds,
90113 * and triggering the build of the host derivation (cross built - crossDrv). */
91114 mapTestOnCross = crossSystem: mapAttrsRecursive
92− (path: systems: testOnCross crossSystem systems
115+ (path: metaPatterns: testOnCross crossSystem metaPatterns
93116 (pkgs: addMetaAttrs { maintainers = crossMaintainers; } (getAttrFromPath path pkgs)));
94117
95118
@@ -98,12 +121,8 @@ rec {
98121 packagePlatforms = mapAttrs (name: value:
99122 let res = builtins.tryEval (
100123 if isDerivation value then
101− value.meta.hydraPlatforms or (let
102− linuxDefaulted = value.meta.platforms or [ "x86_64-linux" ];
103− pred = system: lib.any
104− (lib.meta.platformMatch (lib.systems.elaborate { inherit system; }))
105− linuxDefaulted;
106− in lib.filter pred supportedSystems)
124+ value.meta.hydraPlatforms
125+ or supportedMatches (value.meta.platforms or [ "x86_64-linux" ])
107126 else if value.recurseForDerivations or false || value.recurseForRelease or false then
108127 packagePlatforms value
109128 else