diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 00000000000..57625d46981 --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,42 @@ +name: Nix + +on: + workflow_dispatch: + inputs: + job: + description: Nix job to run + type: choice + options: + - check + - build + default: check + pull_request: + types: [labeled] + +permissions: + contents: read + +concurrency: + group: nix-${{ github.ref }} + cancel-in-progress: true + +jobs: + nix: + if: github.event_name == 'workflow_dispatch' || github.event.label.name == 'ci/nix' + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest] + runs-on: ${{ matrix.os }} + timeout-minutes: 45 + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - name: Set up Nix + uses: ./.github/actions/nix-setup + with: + cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }} + + - name: Run Nix job + run: scripts/nix-ci.sh "${{ github.event.inputs.job || 'check' }}" diff --git a/scripts/nix-ci.sh b/scripts/nix-ci.sh new file mode 100755 index 00000000000..e4ac7b56dbb --- /dev/null +++ b/scripts/nix-ci.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +set -euo pipefail + +case "${1:-check}" in + check) + nix flake check --print-build-logs + ;; + build) + nix build .#default .#tui .#web .#desktop \ + --no-link --print-build-logs + ;; + *) + echo "Usage: $0 [check|build]" >&2 + exit 2 + ;; +esac