summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-11-09 11:28:59 -0500
committerMarge Bot <ben+marge-bot@smart-cactus.org>2021-11-16 03:12:34 -0500
commita8e1a75673e9c79a1504f16e87c6bd57488b3fbc (patch)
tree08dee01d7ab1033c0ec2b8f97bdc6c63afc3e472
parentcc635da167fdec2dead0603b0026cb841f0aa645 (diff)
downloadhaskell-a8e1a75673e9c79a1504f16e87c6bd57488b3fbc.tar.gz
gitlab-ci: Refactor toolchain provision
This makes it easier to invoke ci.sh on Darwin by teaching it to manage the nix business.
-rw-r--r--.gitlab-ci.yml10
-rwxr-xr-x.gitlab/ci.sh36
2 files changed, 28 insertions, 18 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 77958e29f3..497cb02e21 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -544,6 +544,7 @@ validate-x86_64-darwin:
- x86_64-darwin-m1
variables:
+ NIX_SYSTEM: x86_64-darwin
BUILD_FLAVOUR: "validate"
GHC_VERSION: 8.10.4
CABAL_INSTALL_VERSION: 3.2.0.0
@@ -573,10 +574,6 @@ validate-x86_64-darwin:
- cat ci-timings
script: |
- nix build -f .gitlab/darwin/toolchain.nix --argstr system x86_64-darwin -o toolchain.sh
- source toolchain.sh
- cat toolchain.sh
-
sdk_path="$(xcrun --sdk macosx --show-sdk-path)"
CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi"
@@ -603,6 +600,7 @@ validate-aarch64-darwin:
- aarch64-darwin-m1
variables:
+ NIX_SYSTEM: aarch64-darwin
BUILD_FLAVOUR: "validate"
TEST_TYPE: test
MAKE_ARGS: "-Werror"
@@ -629,10 +627,6 @@ validate-aarch64-darwin:
# behave very differently. -i bash does not pass any nix related env vars
# the whole $stdenv/setup part seems to be missing.
script: |
- nix build -f .gitlab/darwin/toolchain.nix --argstr system aarch64-darwin -o toolchain.sh
- source toolchain.sh
- cat toolchain.sh
-
sdk_path="$(xcrun --sdk macosx --show-sdk-path)"
CONFIGURE_ARGS="$CONFIGURE_ARGS --with-ffi-libraries=$sdk_path/usr/lib --with-ffi-includes=$sdk_path/usr/include/ffi"
diff --git a/.gitlab/ci.sh b/.gitlab/ci.sh
index 9b68799e37..e76a5d912b 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -70,6 +70,8 @@ Environment variables affecting both build systems:
INSTALL_CONFIGURE_ARGS
Arguments passed to the binary distribution configure script
during installation of test toolchain.
+ NIX_SYSTEM On Darwin, the target platform of the desired toolchain
+ (either "x86-64-darwin" or "aarch-darwin")
Environment variables determining build configuration of Make system:
@@ -182,22 +184,33 @@ function show_tool() {
}
function set_toolchain_paths() {
- needs_toolchain="1"
case "$(uname -m)-$(uname)" in
# Linux toolchains are included in the Docker image
- *-Linux) needs_toolchain="" ;;
+ *-Linux) toolchain_source="env" ;;
# Darwin toolchains are provided via .gitlab/darwin/toolchain.nix
- *-Darwin) needs_toolchain="" ;;
- *) ;;
+ *-Darwin) toolchain_source="nix" ;;
+ *) toolchain_source="extracted" ;;
esac
- if [[ -n "$needs_toolchain" ]]; then
+ case "$toolchain_source" in
+ extracted)
# These are populated by setup_toolchain
GHC="$toolchain/bin/ghc$exe"
CABAL="$toolchain/bin/cabal$exe"
HAPPY="$toolchain/bin/happy$exe"
ALEX="$toolchain/bin/alex$exe"
- else
+ ;;
+ nix)
+ if [[ ! -f toolchain.sh ]]; then
+ case "$NIX_SYSTEM" in
+ x86_64-darwin|aarch64-darwin) ;;
+ *) fail "unknown NIX_SYSTEM" ;;
+ esac
+ nix build -f .gitlab/darwin/toolchain.nix --argstr system "$NIX_SYSTEM" -o toolchain.sh
+ cat toolchain.sh
+ fi
+ source toolchain.sh ;;
+ env)
# These are generally set by the Docker image but
# we provide these handy fallbacks in case the
# script isn't run from within a GHC CI docker image.
@@ -205,7 +218,9 @@ function set_toolchain_paths() {
if [ -z "$CABAL" ]; then CABAL="$(which cabal)"; fi
if [ -z "$HAPPY" ]; then HAPPY="$(which happy)"; fi
if [ -z "$ALEX" ]; then ALEX="$(which alex)"; fi
- fi
+ ;;
+ *) fail "bad toolchain_source"
+ esac
export GHC
export CABAL
@@ -227,9 +242,10 @@ function setup() {
cp -Rf "$CABAL_CACHE"/* "$CABAL_DIR"
fi
- if [[ "$needs_toolchain" = "1" ]]; then
- time_it "setup" setup_toolchain
- fi
+ case $toolchain_source in
+ extracted) time_it "setup" setup_toolchain ;;
+ *) ;;
+ esac
cabal_update