Skip to content

Build flake outputs #382

Build flake outputs

Build flake outputs #382

Workflow file for this run

---
name: Cachix
on:
push:
pull_request:
workflow_dispatch:
run-name: "Build flake outputs"
# Builds can cancel other in-progress builds on the same ref.
concurrency:
group: ${{ github.workflow }}-build-${{ github.ref }}
cancel-in-progress: true
jobs:
check-flake:
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Check flake
run: nix flake check --keep-going --impure # devenv requires impure
determine-hosts:
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
needs: [check-flake]
outputs:
hosts: ${{ steps.generate.outputs.hosts }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- id: generate
name: Generate hosts list
run: |
hosts=$(nix flake show --impure --json . | jq -c '.nixosConfigurations | keys')
printf '%s' "hosts=$hosts" >> "$GITHUB_OUTPUT"
build-hosts:
runs-on: ubuntu-22.04
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
needs: [determine-hosts]
strategy:
fail-fast: false
matrix:
host: ${{ fromJson(needs.determine-hosts.outputs.hosts) }}
steps:
- uses: jlumbroso/free-disk-space@v1.3.1
with:
tool-cache: true
swap-storage: false
- uses: actions/checkout@v4
- name: Build ${{ matrix.host }}
uses: ./.github/actions/build
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
cachix-auth-token: ${{ secrets.CACHIX_AUTH_TOKEN }}
derivation: ".#nixosConfigurations.${{ matrix.host }}.config.system.build.toplevel"
cachix-extra-pull-names: "nix-gaming, hyprland, nix-community"
build-result: # https://github.com/orgs/community/discussions/26822#discussioncomment-5122101
runs-on: ubuntu-22.04
needs: [build-hosts]
if: ${{ (failure() || success()) && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name) }}
steps:
- if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1