lol
1{ supportedSystems, packageSet ? (import ./all-packages.nix), allowTexliveBuilds ? false }:
2
3with import ../../lib;
4
5rec {
6
7 # Ensure that we don't build packages marked as unfree.
8 allPackages = args: packageSet (args // {
9 config.allowUnfree = false;
10 config.allowTexliveBuilds = allowTexliveBuilds;
11 config.inHydra = true;
12 });
13
14 pkgs = pkgsFor "x86_64-linux";
15
16
17 /* !!! Hack: poor man's memoisation function. Necessary to prevent
18 Nixpkgs from being evaluated again and again for every
19 job/platform pair. */
20 pkgsFor = system:
21 if system == "x86_64-linux" then pkgs_x86_64_linux
22 else if system == "i686-linux" then pkgs_i686_linux
23 else if system == "x86_64-darwin" then pkgs_x86_64_darwin
24 else if system == "x86_64-freebsd" then pkgs_x86_64_freebsd
25 else if system == "i686-freebsd" then pkgs_i686_freebsd
26 else if system == "i686-cygwin" then pkgs_i686_cygwin
27 else if system == "x86_64-cygwin" then pkgs_x86_64_cygwin
28 else abort "unsupported system type: ${system}";
29
30 pkgs_x86_64_linux = allPackages { system = "x86_64-linux"; };
31 pkgs_i686_linux = allPackages { system = "i686-linux"; };
32 pkgs_x86_64_darwin = allPackages { system = "x86_64-darwin"; };
33 pkgs_x86_64_freebsd = allPackages { system = "x86_64-freebsd"; };
34 pkgs_i686_freebsd = allPackages { system = "i686-freebsd"; };
35 pkgs_i686_cygwin = allPackages { system = "i686-cygwin"; };
36 pkgs_x86_64_cygwin = allPackages { system = "x86_64-cygwin"; };
37
38
39 /* The working or failing mails for cross builds will be sent only to
40 the following maintainers, as most package maintainers will not be
41 interested in the result of cross building a package. */
42 crossMaintainers = [ maintainers.viric ];
43
44
45 /* Build a package on the given set of platforms. The function `f'
46 is called for each supported platform with Nixpkgs for that
47 platform as an argument . We return an attribute set containing
48 a derivation for each supported platform, i.e. ‘{ x86_64-linux =
49 f pkgs_x86_64_linux; i686-linux = f pkgs_i686_linux; ... }’. */
50 testOn = systems: f: genAttrs
51 (filter (x: elem x supportedSystems) systems) (system: hydraJob (f (pkgsFor system)));
52
53
54 /* Similar to the testOn function, but with an additional
55 'crossSystem' parameter for allPackages, defining the target
56 platform for cross builds. */
57 testOnCross = crossSystem: systems: f: {system ? builtins.currentSystem}:
58 if elem system systems
59 then f (allPackages { inherit system crossSystem; })
60 else {};
61
62
63 /* Given a nested set where the leaf nodes are lists of platforms,
64 map each leaf node to `testOn [platforms...] (pkgs:
65 pkgs.<attrPath>)'. */
66 mapTestOn = mapAttrsRecursive
67 (path: systems: testOn systems (pkgs: getAttrFromPath path pkgs));
68
69
70 /* Similar to the testOn function, but with an additional 'crossSystem'
71 * parameter for allPackages, defining the target platform for cross builds,
72 * and triggering the build of the host derivation (cross built - crossDrv). */
73 mapTestOnCross = crossSystem: mapAttrsRecursive
74 (path: systems: testOnCross crossSystem systems
75 (pkgs: addMetaAttrs { maintainers = crossMaintainers; } (getAttrFromPath path pkgs)));
76
77
78 /* Recursively map a (nested) set of derivations to an isomorphic
79 set of meta.platforms values. */
80 packagePlatforms = mapAttrs (name: value:
81 let res = builtins.tryEval (
82 if isDerivation value then
83 value.meta.hydraPlatforms or (value.meta.platforms or [])
84 else if value.recurseForDerivations or false || value.recurseForRelease or false then
85 packagePlatforms value
86 else
87 []);
88 in if res.success then res.value else []
89 );
90
91
92 /* Common platform groups on which to test packages. */
93 inherit (platforms) unix linux darwin cygwin allBut all mesaPlatforms;
94
95 /* Platform groups for specific kinds of applications. */
96 x11Supported = linux;
97 gtkSupported = linux;
98 ghcSupported = linux;
99
100}