Skip to content
Snippets Groups Projects
Commit a02417d9 authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

ci: minor nix-in-docker improvements

This patch makes some minor improvements re nix-in-docker logic in the
ci configuration:

- Update `nixos/nix` to the latest version
- Apply $CPUS to `cores`/`max-jobs` to avoid oversubscribing while
  allowing a reasonable degree of parallelism
- Remove redundant `--extra-experimental-features nix-command` in
  later `nix shell` invocations, it's already configured in
  `/etc/nix/nix.conf`

(cherry picked from commit 291388e1)
parent f7ff6a9c
No related branches found
No related tags found
No related merge requests found
...@@ -289,7 +289,7 @@ lint-author: ...@@ -289,7 +289,7 @@ lint-author:
- *drafts-can-fail-lint - *drafts-can-fail-lint
lint-ci-config: lint-ci-config:
image: nixos/nix:2.14.1 image: nixos/nix:2.25.3
extends: .lint extends: .lint
# We don't need history/submodules in this job # We don't need history/submodules in this job
variables: variables:
...@@ -299,10 +299,16 @@ lint-ci-config: ...@@ -299,10 +299,16 @@ lint-ci-config:
- echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf - echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
# Note [Nix-in-Docker] # Note [Nix-in-Docker]
# ~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~
# FIXME: This is a workaround for a Nix-in-Docker issue. See # The nixos/nix default config is max-jobs=1 and cores=$(logical
# cores num) which doesn't play nice with our $CPUS convention. We
# fix it before invoking any nix build to avoid oversubscribing
# while allowing a reasonable degree of parallelism.
# FIXME: Disabling build-users-group=nixbld is a workaround for a Nix-in-Docker issue. See
# https://gitlab.haskell.org/ghc/head.hackage/-/issues/38#note_560487 for # https://gitlab.haskell.org/ghc/head.hackage/-/issues/38#note_560487 for
# discussion. # discussion.
- nix-shell -p gnused --run "sed -i -e 's/nixbld//' /etc/nix/nix.conf" - echo "cores = $CPUS" >> /etc/nix/nix.conf
- echo "max-jobs = $CPUS" >> /etc/nix/nix.conf
- nix run nixpkgs#gnused -- -i -e 's/ nixbld//' /etc/nix/nix.conf
script: script:
- nix run .gitlab/generate-ci#generate-jobs - nix run .gitlab/generate-ci#generate-jobs
# 1 if .gitlab/generate_jobs changed the output of the generated config # 1 if .gitlab/generate_jobs changed the output of the generated config
...@@ -1110,7 +1116,7 @@ project-version: ...@@ -1110,7 +1116,7 @@ project-version:
.ghcup-metadata: .ghcup-metadata:
stage: deploy stage: deploy
image: nixos/nix:2.14.1 image: nixos/nix:2.25.3
dependencies: null dependencies: null
tags: tags:
- x86_64-linux - x86_64-linux
...@@ -1120,7 +1126,9 @@ project-version: ...@@ -1120,7 +1126,9 @@ project-version:
before_script: before_script:
- echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf - echo "experimental-features = nix-command flakes" >> /etc/nix/nix.conf
# FIXME: See Note [Nix-in-Docker] # FIXME: See Note [Nix-in-Docker]
- nix-shell -p gnused --run "sed -i -e 's/nixbld//' /etc/nix/nix.conf" - echo "cores = $CPUS" >> /etc/nix/nix.conf
- echo "max-jobs = $CPUS" >> /etc/nix/nix.conf
- nix run nixpkgs#gnused -- -i -e 's/ nixbld//' /etc/nix/nix.conf
- nix-channel --update - nix-channel --update
- cat version.sh - cat version.sh
# Calculate the project version # Calculate the project version
...@@ -1185,7 +1193,7 @@ ghcup-metadata-nightly: ...@@ -1185,7 +1193,7 @@ ghcup-metadata-nightly:
artifacts: false artifacts: false
- job: project-version - job: project-version
script: script:
- nix shell --extra-experimental-features nix-command -f .gitlab/rel_eng -c ghcup-metadata --metadata ghcup-0.0.7.yaml --date="$(date -d $CI_PIPELINE_CREATED_AT +%Y-%m-%d)" --pipeline-id="$CI_PIPELINE_ID" --version="$ProjectVersion" > "metadata_test.yaml" - nix shell -f .gitlab/rel_eng -c ghcup-metadata --metadata ghcup-0.0.7.yaml --date="$(date -d $CI_PIPELINE_CREATED_AT +%Y-%m-%d)" --pipeline-id="$CI_PIPELINE_ID" --version="$ProjectVersion" > "metadata_test.yaml"
rules: rules:
- if: $NIGHTLY - if: $NIGHTLY
...@@ -1223,8 +1231,8 @@ ghcup-metadata-release: ...@@ -1223,8 +1231,8 @@ ghcup-metadata-release:
# No explicit needs for release pipeline as we assume we need everything and everything will pass. # No explicit needs for release pipeline as we assume we need everything and everything will pass.
extends: .ghcup-metadata extends: .ghcup-metadata
script: script:
- nix shell --extra-experimental-features nix-command -f .gitlab/rel_eng -c ghcup-metadata --release-mode --metadata ghcup-0.0.7.yaml --date="$(date -d $CI_PIPELINE_CREATED_AT +%Y-%m-%d)" --pipeline-id="$CI_PIPELINE_ID" --version="$ProjectVersion" --fragment - nix shell -f .gitlab/rel_eng -c ghcup-metadata --release-mode --metadata ghcup-0.0.7.yaml --date="$(date -d $CI_PIPELINE_CREATED_AT +%Y-%m-%d)" --pipeline-id="$CI_PIPELINE_ID" --version="$ProjectVersion" --fragment
- nix shell --extra-experimental-features nix-command -f .gitlab/rel_eng -c ghcup-metadata --release-mode --metadata ghcup-0.0.7.yaml --date="$(date -d $CI_PIPELINE_CREATED_AT +%Y-%m-%d)" --pipeline-id="$CI_PIPELINE_ID" --version="$ProjectVersion" > "metadata_test.yaml" - nix shell -f .gitlab/rel_eng -c ghcup-metadata --release-mode --metadata ghcup-0.0.7.yaml --date="$(date -d $CI_PIPELINE_CREATED_AT +%Y-%m-%d)" --pipeline-id="$CI_PIPELINE_ID" --version="$ProjectVersion" > "metadata_test.yaml"
rules: rules:
- if: '$RELEASE_JOB == "yes"' - if: '$RELEASE_JOB == "yes"'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment