Skip to content

Commit 994a3ae

Browse files
committed
add matrix.nix for matrix build using all packages and compilers
Uses ci.dhall as a single source of truth (ci.dhall.frozen which is now-autoupdated via ci.sh)
1 parent 440dba1 commit 994a3ae

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

.github/workflows/ci.dhall.frozen

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
let haskellCi =
2+
https://raw.githubusercontent.com/sorki/github-actions-dhall/main/haskell-ci.dhall
3+
sha256:9e49c0d57a38ab766825b3d2de6656d998b15eec873982db97d590ef58298601
4+
5+
let defSteps = haskellCi.defaultCabalSteps
6+
7+
in haskellCi.generalCi
8+
( haskellCi.withNix
9+
( defSteps
10+
with extraSteps.pre
11+
=
12+
defSteps.extraSteps.pre
13+
# [ haskellCi.installCachixStep "hnix-store"
14+
, haskellCi.BuildStep.NameIf
15+
{ name = "Install libsodium"
16+
, run = "sudo apt install libsodium-dev"
17+
, `if` = "matrix.os == 'ubuntu-latest'"
18+
}
19+
]
20+
)
21+
)
22+
haskellCi.DhallMatrix::{
23+
, ghc =
24+
[ haskellCi.GHC.GHC963
25+
, haskellCi.GHC.GHC947
26+
, haskellCi.GHC.GHC902
27+
, haskellCi.GHC.GHC8107
28+
]
29+
, os = [ haskellCi.OS.Ubuntu, haskellCi.OS.MacOS ]
30+
}
31+
: haskellCi.CI.Type

.github/workflows/ci.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@
44
set -eo pipefail
55
cd "$( dirname "${BASH_SOURCE[0]}" )"
66

7+
which dhall || cabal install dhall
78
which dhall-to-yaml || cabal install dhall-yaml
9+
10+
echo "cp haskellCi.dhall -> ci.dhall.frozen"
11+
cp ci.dhall ci.dhall.frozen
12+
echo "dhall freez-ing ci.dhall.frozen"
13+
dhall freeze ci.dhall.frozen
814
echo "regenerating ci.yaml"
915
dhall-to-yaml-ng --generated-comment --file ci.dhall > ci.yaml

matrix.nix

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Matrix build for all packages and compilers
2+
#
3+
# Uses ./.github/workflows/ci.dhall as a single source of
4+
# truth for a list of supported compilers
5+
#
6+
# The dhall expression needs to be frozen via dhall freeze
7+
# which is done automatically when we update it via ./.github/workflows/ci.sh
8+
# and dhallDirectoryToNix uses ci.dhall.frozen instead
9+
{ pkgs ? import <nixpkgs> {}
10+
}:
11+
let
12+
lib = pkgs.lib;
13+
ciDhallNix = pkgs.dhallDirectoryToNix { src = ./.github/workflows; file = "ci.dhall.frozen"; };
14+
ciCompilers = ciDhallNix.jobs.build.strategy.matrix.ghc;
15+
16+
# from e.g. 9.6.3 to ghc963
17+
convertCompilers = cs:
18+
map (x: "ghc${lib.strings.replaceStrings ["."] [""] x}") cs;
19+
20+
compilers =
21+
lib.traceValFn (cs:
22+
let
23+
prettyCs = lib.concatMapStringsSep "\n" (c: "- ${c}") cs;
24+
in
25+
"building for compilers:\n${prettyCs}")
26+
(convertCompilers ciCompilers);
27+
in
28+
pkgs.lib.recurseIntoAttrs
29+
(pkgs.lib.genAttrs compilers (compiler:
30+
pkgs.lib.recurseIntoAttrs
31+
(import ./. { inherit pkgs compiler; })
32+
)
33+
)

0 commit comments

Comments
 (0)