on fa2fa13 help sign in
haskell.nix/ci.nix
117 lines 6.9 kB history raw
1# 'supportedSystems' restricts the set of systems that we will evaluate for. Useful when you're evaluating
2# on a machine with e.g. no way to build the Darwin IFDs you need!
3{ supportedSystems ? [ "x86_64-linux" "x86_64-darwin" ]
4, ifdLevel ? 3
5# Whether or not we are evaluating in restricted mode. This is true in Hydra, but not in Hercules.
6, restrictEval ? false
7, checkMaterialization ? false
8, pkgs ? (import ./. {}).pkgs }:
9 let
10 inherit (import ./ci-lib.nix { inherit pkgs; }) dimension platformFilterGeneric filterAttrsOnlyRecursive;
11 inherit (pkgs.haskell-nix) sources;
12 nixpkgsVersions = {
13 "R2111" = "nixpkgs-2111";
14 "unstable" = "nixpkgs-unstable";
15 };
16 compilerNixNames = nixpkgsName: nixpkgs: builtins.mapAttrs (compiler-nix-name: runTests: {
17 inherit (import ./default.nix { inherit checkMaterialization; }) nixpkgsArgs;
18 inherit runTests;
19 }) (
20 # GHC version to cache and whether to run the tests against them.
21 # This list of GHC versions should include everything for which we
22 # have a ./materialized/ghcXXX directory containing the materialized
23 # cabal-install and nix-tools plans. When removing a ghc version
24 # from here (so that is no longer cached) also remove ./materialized/ghcXXX.
25 # Update supported-ghc-versions.md to reflect any changes made here.
26 nixpkgs.lib.optionalAttrs (nixpkgsName == "R2111") {
27 ghc865 = false;
28 ghc8107 = true;
29 } // nixpkgs.lib.optionalAttrs (nixpkgsName == "unstable") {
30 ghc865 = false;
31 ghc884 = false; # Native version is used to boot 9.0.1
32 ghc8107 = true;
33 ghc902 = true;
34 ghc923 = true;
35 });
36 systems = nixpkgsName: nixpkgs: compiler-nix-name: nixpkgs.lib.genAttrs (
37 nixpkgs.lib.filter (v:
38 # We have less x86_64-darwin build capacity so build fewer GhC versions
39 (v != "x86_64-darwin" || (
40 !__elem compiler-nix-name ["ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]))
41 &&
42 # aarch64-darwin requires ghc 8.10.7
43 (v != "aarch64-darwin" || (
44 !__elem compiler-nix-name ["ghc865" "ghc884" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]))
45 &&
46 # aarch64-linux requires ghc 8.8.4
47 (v != "aarch64-linux" || (
48 !__elem compiler-nix-name ["ghc865" "ghc8104" "ghc810420210212" "ghc8105" "ghc8106" "ghc901" "ghc921" "ghc922"]
49 ))) supportedSystems) (v: v);
50 crossSystems = nixpkgsName: nixpkgs: compiler-nix-name: system:
51 # We need to use the actual nixpkgs version we're working with here, since the values
52 # of 'lib.systems.examples' are not understood between all versions
53 let lib = nixpkgs.lib;
54 in lib.optionalAttrs (nixpkgsName == "unstable"
55 && ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc865" "ghc884" "ghc8107"])
56 || (system == "x86_64-darwin" && __elem compiler-nix-name ["ghc8107"]))) {
57 inherit (lib.systems.examples) ghcjs;
58 } // lib.optionalAttrs (nixpkgsName == "unstable"
59 && ((system == "x86_64-linux" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc923"])
60 || (system == "x86_64-darwin" && __elem compiler-nix-name []))) { # TODO add ghc versions when we have more darwin build capacity
61 inherit (lib.systems.examples) mingwW64;
62 } // lib.optionalAttrs (system == "x86_64-linux" && nixpkgsName == "unstable" && __elem compiler-nix-name ["ghc8107" "ghc902" "ghc922" "ghc923"]) {
63 # Musl cross only works on linux
64 # aarch64 cross only works on linux
65 inherit (lib.systems.examples) musl64 aarch64-multiplatform;
66 };
67 isDisabled = d: d.meta.disabled or false;
68in
69dimension "Nixpkgs version" nixpkgsVersions (nixpkgsName: nixpkgs-pin:
70 let pinnedNixpkgsSrc = sources.${nixpkgs-pin};
71 # We need this for generic nixpkgs stuff at the right version
72 genericPkgs = import pinnedNixpkgsSrc {};
73 in dimension "GHC version" (compilerNixNames nixpkgsName genericPkgs) (compiler-nix-name: {nixpkgsArgs, runTests}:
74 dimension "System" (systems nixpkgsName genericPkgs compiler-nix-name) (systemName: system:
75 let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system; });
76 build = import ./build.nix { inherit pkgs ifdLevel compiler-nix-name; };
77 platformFilter = platformFilterGeneric pkgs system;
78 in filterAttrsOnlyRecursive (_: v: platformFilter v && !(isDisabled v)) ({
79 # Native builds
80 # TODO: can we merge this into the general case by picking an appropriate "cross system" to mean native?
81 native = pkgs.recurseIntoAttrs ({
82 roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
83 ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";
84 } // pkgs.lib.optionalAttrs runTests {
85 inherit (build) tests tools maintainer-scripts maintainer-script-cache;
86 } // pkgs.lib.optionalAttrs (ifdLevel >= 1) {
87 iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
88 } // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
89 hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit compiler-nix-name; }).getComponent "exe:hello";
90 });
91 }
92 //
93 dimension "Cross system" (crossSystems nixpkgsName genericPkgs compiler-nix-name system) (crossSystemName: crossSystem:
94 # Cross builds
95 let pkgs = import pinnedNixpkgsSrc (nixpkgsArgs // { inherit system crossSystem; });
96 build = import ./build.nix { inherit pkgs ifdLevel compiler-nix-name; };
97 in pkgs.recurseIntoAttrs (pkgs.lib.optionalAttrs (ifdLevel >= 1) ({
98 roots = pkgs.haskell-nix.roots' compiler-nix-name ifdLevel;
99 ghc = pkgs.buildPackages.haskell-nix.compiler."${compiler-nix-name}";
100 # TODO: look into cross compiling ghc itself
101 # ghc = pkgs.haskell-nix.compiler."${compiler-nix-name}";
102 # TODO: look into making tools work when cross compiling
103 # inherit (build) tools;
104 } // pkgs.lib.optionalAttrs (runTests && crossSystemName != "aarch64-multiplatform") {
105 # Tests are broken on aarch64 cross https://github.com/input-output-hk/haskell.nix/issues/513
106 inherit (build) tests;
107 }) // pkgs.lib.optionalAttrs (ifdLevel >= 2 && crossSystemName != "ghcjs") {
108 # GHCJS builds its own template haskell runner.
109 remote-iserv = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "remote-iserv:exe:remote-iserv";
110 iserv-proxy = pkgs.ghc-extra-projects."${compiler-nix-name}".getComponent "iserv-proxy:exe:iserv-proxy";
111 } // pkgs.lib.optionalAttrs (ifdLevel >= 3) {
112 hello = (pkgs.haskell-nix.hackage-package { name = "hello"; version = "1.0.0.2"; inherit compiler-nix-name; }).getComponent "exe:hello";
113 })
114 ))
115 )
116 )