name: 🏗️ Build QOwnNotes for Nix

on:
  push:
    branches-ignore:
      - release
    tags-ignore:
      - "*"
    paths:
      - "src/**"
      - "shell.nix"
      - "default.nix"
      - "build-systems/nix/**"
      - ".github/workflows/build-nix.yml"
  pull_request:
    paths:
      - "src/**"
      - "shell.nix"
      - "default.nix"
      - "build-systems/nix/**"
      - ".github/workflows/build-nix.yml"
  workflow_dispatch:

jobs:
  build:
    name: 🏗️ Build ${{ matrix.just-recipe }} on ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        just-recipe: ["nix-build", "nix-build-cmake-qt5"]
        os: ["ubuntu-latest", "macos-latest", "macos-14"]
    steps:
      - name: ⚙️ Install Nix
        uses: cachix/install-nix-action@v31
        with:
          nix_path: nixpkgs=channel:nixos-unstable
      - name: 🧰 Checkout code
        uses: actions/checkout@v4
        with:
          submodules: recursive
      - name: 🚧 Build nix package
        run: nix-shell --run "just ${{ matrix.just-recipe }}"
