name: CI

on: [push, pull_request]

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.event_name != 'push' }}

jobs:
  nix:
    name: Build
    strategy:
      matrix:
        system:
          - runs-on: ubuntu-24.04
            nix-system: x86_64-linux
          - runs-on: ubuntu-24.04-arm
            nix-system: aarch64-linux
    runs-on: ${{ matrix.system.runs-on }}
    steps:
      - uses: actions/checkout@v5

      - uses: DeterminateSystems/nix-installer-action@main
      - uses: DeterminateSystems/magic-nix-cache-action@main
        with:
          use-flakehub: false

      - name: Check flake
        run: nix flake check --system ${{ matrix.system.nix-system }}

      - name: Build
        run: nix build .#nixtopsy --system ${{ matrix.system.nix-system }}
