summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBen Gamari <ben@smart-cactus.org>2021-11-09 11:28:59 -0500
committerBen Gamari <ben@smart-cactus.org>2021-12-09 11:53:12 -0500
commit033e0b1eec51bcb221c5372eb4acfa632c73e8b9 (patch)
tree1af7c5c2dbb5f78239c6eef15d92b4c9ebc1e53f
parentc718d55b2bd3f6016901ccf0706e36311df79b81 (diff)
downloadhaskell-033e0b1eec51bcb221c5372eb4acfa632c73e8b9.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. (cherry picked from commit a8e1a75673e9c79a1504f16e87c6bd57488b3fbc)
-rw-r--r--.gitlab-ci.yml10
-rwxr-xr-x.gitlab/ci.sh38
2 files changed, 28 insertions, 20 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 20a11dc68d..b5d7351a02 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -533,6 +533,7 @@ validate-x86_64-darwin:
allow_failure: true
variables:
+ NIX_SYSTEM: x86_64-darwin
BUILD_FLAVOUR: "validate"
GHC_VERSION: 8.10.4
CABAL_INSTALL_VERSION: 3.2.0.0
@@ -564,10 +565,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"
@@ -594,6 +591,7 @@ validate-aarch64-darwin:
- aarch64-darwin-m1
variables:
+ NIX_SYSTEM: aarch64-darwin
BUILD_FLAVOUR: "validate"
TEST_TYPE: test
MAKE_ARGS: "-Werror"
@@ -620,10 +618,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 3c907f8c4e..1ca163dff3 100755
--- a/.gitlab/ci.sh
+++ b/.gitlab/ci.sh
@@ -67,6 +67,8 @@ Environment variables affecting both build systems:
Whether to ignore perf failures (one of "increases",
"decreases", or "all")
HERMETIC Take measures to avoid looking at anything in \$HOME
+ 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:
@@ -179,24 +181,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 [ -z "${CC:-}" ]; then CC="$(which cc)"; fi
-
- 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.
@@ -204,7 +215,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 CC
export GHC
@@ -227,9 +240,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