name: Validate Nix Flake

on:
  workflow_dispatch:
  push:
    paths:
      - "**.nix"
      - "**.lock"
      - ".github/workflows/check.yml"
      - ".github/actions/**/*"

permissions: {}

jobs:
  check-flake:
    name: Check (${{ matrix.system }})
    runs-on: ${{ matrix.os }}

    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            system: x86_64-linux
          - os: macos-latest
            system: aarch64-darwin

    steps:
      - name: Checkout
        uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false

      - name: Install Lix
        uses: ./.github/actions/install-lix

      - name: Check Flake
        run: nix flake check --show-trace --option allow-import-from-derivation false
