From cc9c2dceb87e54569f095f2faf0f6801ef42f29e Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sun, 21 Dec 2025 11:05:31 +0100 Subject: [PATCH] fix(ci,nix): forward NIX_CONFIG into docker build and runtime to avoid GitHub rate limits - Export NIX_CONFIG in CI jobs and Makefile - Pass NIX_CONFIG as docker build-arg - Use NIX_CONFIG only in relevant Dockerfile RUN steps (no secret persistence) - Forward NIX_CONFIG to test and deploy containers https://chatgpt.com/share/6947c681-abc8-800f-ba12-de2ff3a7abad --- .github/workflows/test-code-integration.yml | 3 +++ .github/workflows/test-code-lint.yml | 3 +++ .github/workflows/test-code-unit.yml | 3 +++ .github/workflows/test-deploy-server.yml | 3 +++ .github/workflows/test-deploy-universal.yml | 3 +++ .github/workflows/test-deploy-workstation.yml | 3 +++ .github/workflows/test-install-make.yml | 3 +++ .github/workflows/test-install-pkgmgr.yml | 3 +++ Dockerfile | 5 +++++ Makefile | 4 ++++ scripts/build/image.sh | 8 ++++++++ scripts/tests/code.sh | 1 + scripts/tests/deploy.sh | 6 +++++- 13 files changed, 47 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test-code-integration.yml b/.github/workflows/test-code-integration.yml index 4366aedef6..0b278ebb61 100644 --- a/.github/workflows/test-code-integration.yml +++ b/.github/workflows/test-code-integration.yml @@ -11,6 +11,9 @@ jobs: test-code-integration: runs-on: ubuntu-latest timeout-minutes: 15 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository diff --git a/.github/workflows/test-code-lint.yml b/.github/workflows/test-code-lint.yml index 73ed7aff9c..8100aea2ff 100644 --- a/.github/workflows/test-code-lint.yml +++ b/.github/workflows/test-code-lint.yml @@ -11,6 +11,9 @@ jobs: test-code-lint: runs-on: ubuntu-latest timeout-minutes: 30 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository diff --git a/.github/workflows/test-code-unit.yml b/.github/workflows/test-code-unit.yml index be0f73f9e9..0b352f8f18 100644 --- a/.github/workflows/test-code-unit.yml +++ b/.github/workflows/test-code-unit.yml @@ -10,6 +10,9 @@ jobs: test-unit: runs-on: ubuntu-latest timeout-minutes: 30 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} steps: - name: Checkout repository diff --git a/.github/workflows/test-deploy-server.yml b/.github/workflows/test-deploy-server.yml index 2e96c47c5b..6f6e886f44 100644 --- a/.github/workflows/test-deploy-server.yml +++ b/.github/workflows/test-deploy-server.yml @@ -11,6 +11,9 @@ jobs: test-deploy: runs-on: ubuntu-latest timeout-minutes: 240 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false diff --git a/.github/workflows/test-deploy-universal.yml b/.github/workflows/test-deploy-universal.yml index 45f2b5d29c..6c45bc911d 100644 --- a/.github/workflows/test-deploy-universal.yml +++ b/.github/workflows/test-deploy-universal.yml @@ -11,6 +11,9 @@ jobs: test-deploy: runs-on: ubuntu-latest timeout-minutes: 240 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false diff --git a/.github/workflows/test-deploy-workstation.yml b/.github/workflows/test-deploy-workstation.yml index 089e918a04..0d8d0ae737 100644 --- a/.github/workflows/test-deploy-workstation.yml +++ b/.github/workflows/test-deploy-workstation.yml @@ -11,6 +11,9 @@ jobs: test-deploy: runs-on: ubuntu-latest timeout-minutes: 240 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false diff --git a/.github/workflows/test-install-make.yml b/.github/workflows/test-install-make.yml index 33849807f4..02c12bf21a 100644 --- a/.github/workflows/test-install-make.yml +++ b/.github/workflows/test-install-make.yml @@ -11,6 +11,9 @@ jobs: test-install-make: runs-on: ubuntu-latest timeout-minutes: 15 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false matrix: diff --git a/.github/workflows/test-install-pkgmgr.yml b/.github/workflows/test-install-pkgmgr.yml index e9dd1fc406..bab562f97f 100644 --- a/.github/workflows/test-install-pkgmgr.yml +++ b/.github/workflows/test-install-pkgmgr.yml @@ -11,6 +11,9 @@ jobs: test-install-pkgmgr: runs-on: ubuntu-latest timeout-minutes: 15 + env: + NIX_CONFIG: | + access-tokens = github.com=${{ secrets.GITHUB_TOKEN }} strategy: fail-fast: false matrix: diff --git a/Dockerfile b/Dockerfile index f42752d029..f44d95ce06 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,9 @@ FROM ${PKGMGR_IMAGE_REPO}:${PKGMGR_IMAGE_TAG} AS full # Hadolint DL4006: ensure pipefail is set for RUN instructions that use pipes SHELL ["/bin/bash", "-o", "pipefail", "-lc"] +# Forwardable build-time Nix settings (e.g., GitHub access tokens to avoid rate limits) +ARG NIX_CONFIG + ENV INFINITO_SRC_DIR="/opt/src/infinito" ENV PYTHON="/opt/venvs/infinito/bin/python" ENV PIP="/opt/venvs/infinito/bin/python -m pip" @@ -74,6 +77,7 @@ COPY . ${INFINITO_SRC_DIR} # Install infinito via pkgmgr (shallow) # ------------------------------------------------------------ RUN set -euo pipefail; \ + export NIX_CONFIG="${NIX_CONFIG:-}"; \ echo "[docker-infinito] Install Infinito.Nexus via pkgmgr"; \ pkgmgr install infinito --clone-mode shallow; \ echo "[docker-infinito] Installed Infinito.Nexus Version:"; \ @@ -83,6 +87,7 @@ RUN set -euo pipefail; \ # Override with local source # ------------------------------------------------------------ RUN set -euo pipefail; \ + export NIX_CONFIG="${NIX_CONFIG:-}"; \ INSTALL_LOCAL_BUILD=1 /opt/src/infinito/scripts/docker/entry.sh true # Set workdir to / to avoid ambiguous commands diff --git a/Makefile b/Makefile index feb8d30524..3950b746d1 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,10 @@ PIP := $(PYTHON) -m pip export PYTHON export PIP +# Nix Config Variable (To avoid rate limit) +NIX_CONFIG ?= +export NIX_CONFIG + ROLES_DIR := ./roles APPLICATIONS_OUT := ./group_vars/all/04_applications.yml APPLICATIONS_SCRIPT := ./cli/setup/applications/__main__.py diff --git a/scripts/build/image.sh b/scripts/build/image.sh index 79561a0ca7..2d781771dc 100755 --- a/scripts/build/image.sh +++ b/scripts/build/image.sh @@ -47,6 +47,7 @@ Publish options: Notes: - --publish implies --push and requires --registry, --owner, and --version. - Local build (no --push) uses "docker build" and creates local images like "infinito-arch" / "infinito-arch-virgin". +- If you set NIX_CONFIG in the environment (e.g. access-tokens), it will be forwarded into the build. EOF } @@ -151,12 +152,19 @@ if [[ "${PUBLISH}" == "1" ]]; then echo "version = ${VERSION}" echo "stable = ${IS_STABLE}" fi +if [[ -n "${NIX_CONFIG:-}" ]]; then + echo "NIX_CONFIG = " +else + echo "NIX_CONFIG = " +fi echo "------------------------------------------------------------" # Common build args build_args=( --build-arg "PKGMGR_IMAGE_REPO=${PKGMGR_IMAGE_REPO}" --build-arg "PKGMGR_IMAGE_TAG=${PKGMGR_IMAGE_TAG}" + # Forward Nix auth / settings into the build to avoid GitHub API rate limits. + --build-arg "NIX_CONFIG=${NIX_CONFIG:-}" ) if [[ "${NO_CACHE}" == "1" ]]; then diff --git a/scripts/tests/code.sh b/scripts/tests/code.sh index f6f401ffab..6267ac154d 100755 --- a/scripts/tests/code.sh +++ b/scripts/tests/code.sh @@ -9,6 +9,7 @@ docker run --rm \ -e INSTALL_LOCAL_BUILD=1 \ -e TEST_PATTERN="${TEST_PATTERN}" \ -e TEST_TYPE="${TEST_TYPE}" \ + -e NIX_CONFIG="${NIX_CONFIG}" \ -v "$(pwd):/opt/src/infinito" \ "infinito-${INFINITO_DISTRO}" \ bash -lc ' diff --git a/scripts/tests/deploy.sh b/scripts/tests/deploy.sh index fa207b4cd1..0212e10599 100755 --- a/scripts/tests/deploy.sh +++ b/scripts/tests/deploy.sh @@ -83,6 +83,7 @@ join_by_comma() { get_invokable() { set -o pipefail docker run --rm \ + -e NIX_CONFIG="${NIX_CONFIG}" \ -v "${REPO_ROOT}:/opt/src/infinito" \ -w /opt/src/infinito \ "${IMAGE}" \ @@ -207,7 +208,10 @@ EXCLUDE_CSV="$(compute_exclude_csv "${TYPE}")" echo ">>> Excluded roles: ${EXCLUDE_CSV:-}" echo ">>> Preflight: entry.sh inside ${IMAGE}" -docker run --rm --entrypoint bash "${IMAGE}" -lc ' +docker run \ + -e NIX_CONFIG="${NIX_CONFIG}" \ + --rm \ + --entrypoint bash "${IMAGE}" -lc ' set -euo pipefail ls -la /opt/src/infinito/scripts/docker/entry.sh sha256sum /opt/src/infinito/scripts/docker/entry.sh | head -n1