name: Nix Flake Check

on:
  push:
    branches: [main, nix]
    tags:
      - 'v*'
    paths-ignore:
      - 'README.md'
      - 'docs/**'
      - 'www/**'
      - 'helm/**'
  pull_request:
    branches: [main]
    paths-ignore:
      - 'README.md'
      - 'docs/**'
      - 'www/**'
      - 'helm/**'

permissions:
  contents: read

jobs:
  check:
    runs-on: ubuntu-latest
    timeout-minutes: 25

    steps:
      - uses: actions/checkout@v4

      - name: Install Nix
        uses: DeterminateSystems/nix-installer-action@main

      - name: Setup Nix Cache
        uses: DeterminateSystems/magic-nix-cache-action@main

      - name: Check flake
        run: nix flake check

      - name: Show flake info
        run: nix flake show

      - name: Build package
        if: github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')
        run: nix build --print-build-logs
