name: Nix CI

on:
  push:
    branches: [main]
    paths-ignore:
      - '**.md'
      - 'doc/**'
  pull_request:
    branches: [main]
    paths-ignore:
      - '**.md'
      - 'doc/**'

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: ${{ github.ref != 'refs/heads/main' && !startsWith(github.ref, 'refs/tags/') }}

jobs:
  check:
    runs-on: ubuntu-22.04
    permissions:
      id-token: "write"
      contents: "read"
    steps:
      - uses: actions/checkout@v5
      - uses: DeterminateSystems/nix-installer-action@main
      - uses: DeterminateSystems/magic-nix-cache-action@main
      - uses: DeterminateSystems/flake-checker-action@main

      - name: Run `nix flake check`
        run: nix flake check

      - name: Run `nix build`
        run: nix build

      - name: Run `nix build .#fff-nvim`
        run: nix build .#fff-nvim

      - name: Run `nix run .#release`
        run: nix run .#release
