name: Nix (Build)

on:
  workflow_call:
    secrets:
      CACHIX_AUTH_TOKEN:
        required: false

jobs:
  build:
    strategy:
      matrix:
        package:
          - hyprland
          # - hyprland-cross # cross compiling fails due to qt
          # failure chain: hyprland-qtutils -> qt6.qtsvg -> qt6.qtbase -> psqlodbc & qt6.qttranslations
          - xdg-desktop-portal-hyprland

    runs-on: ubuntu-latest
    steps:
      - uses: DeterminateSystems/nix-installer-action@main
      - uses: DeterminateSystems/magic-nix-cache-action@main

      - uses: cachix/cachix-action@v15
        with:
          name: hyprland
          authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

      - run: nix build 'github:hyprwm/Hyprland?ref=${{ github.ref }}#${{ matrix.package }}' -L --extra-substituters "https://hyprland.cachix.org"