name: nix

on: [push, pull_request]

permissions: {}

jobs:
  nix:
    if: github.repository == 'Swatinem/rust-cache'
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, macos-latest]

    name: Test Nix on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}

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

      - uses: cachix/install-nix-action@ab739621df7a23f52766f9ccc97f38da6b7af14f # v31.10.5

      - uses: ./
        with:
          workspaces: tests
          cmd-format: nix develop ./tests -c {0}

      - run: |
          nix develop -c cargo check
          nix develop -c cargo test
        working-directory: tests
