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