From 174ef8c55740c94f7599d49e08500ab0cbbbe745 Mon Sep 17 00:00:00 2001
From: Teo Camarasu <teofilcamarasu@gmail.com>
Date: Wed, 8 Feb 2023 15:13:34 +0000
Subject: [PATCH] nix: set -j1 --cores 1 for first call

The hope is that by limiting concurrent jobs/ CPU usage for the first
call to nix, we will cache the environment without exhausting system
resources.
---
 .gitlab-ci.yml | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 6d1f8c48..dcdc2497 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -79,7 +79,7 @@ variables:
       else
         echo "No cache found"
       fi
-    - GHC_TARBALL=$(nix run -f ./ci -c discover_tarball.sh)
+    - GHC_TARBALL=$(nix run -j1 --cores 1 -f ./ci -c discover_tarball.sh)
   rules:
     - if: '$UPSTREAM_COMMIT_SHA || $UPSTREAM_PIPELINE_ID'
       when: always
@@ -107,7 +107,7 @@ test-pipeline:
       else
         echo "No cache found"
       fi
-    - GHC_TARBALL=$(nix run -f ./ci -c discover_tarball.sh)
+    - GHC_TARBALL=$(nix run -j1 --cores 1 -f ./ci -c discover_tarball.sh)
   variables:
     UPSTREAM_BRANCH_NAME: master
     EXTRA_HC_OPTS: "-dcore-lint"
@@ -161,7 +161,7 @@ test-9.2:
       else
         echo "No cache found"
       fi
-    - GHC_TARBALL=$(nix run -f ./ci -c discover_tarball.sh)
+    - GHC_TARBALL=$(nix run -j1 --cores 1 -f ./ci -c discover_tarball.sh)
   variables:
     UPSTREAM_BRANCH_NAME: ghc-9.4
     EXTRA_HC_OPTS: "-dcore-lint"
@@ -192,7 +192,7 @@ test-9.4:
       else
         echo "No cache found"
       fi
-    - GHC_TARBALL=$(nix run -f ./ci -c discover_tarball.sh)
+    - GHC_TARBALL=$(nix run -j1 --cores 1 -f ./ci -c discover_tarball.sh)
   variables:
     UPSTREAM_BRANCH_NAME: ghc-9.6
     EXTRA_HC_OPTS: "-dcore-lint"
@@ -239,7 +239,7 @@ test-9.6:
   script:
       # Install GHC
     - echo "Bindist tarball is $GHC_TARBALL"
-    - nix run -f ./ci -c curl -L "$GHC_TARBALL" > ghc.tar.xz
+    - nix run -j1 --cores 1 -f ./ci -c curl -L "$GHC_TARBALL" > ghc.tar.xz
     - |
       nix build \
       -f ci/ghc-from-artifact.nix \
-- 
GitLab