  The recent experimental observation of spinor self-ordering of ultracold
atoms in optical resonators has set the stage for the exploration of emergent
magnetic orders in quantum-gas--cavity systems. Based on this platform, we
introduce a generic scheme for the implementation of long-range quantum spin
Hamiltonians composed of various types of couplings, including Heisenberg and
Dzyaloshinskii-Moriya interactions. Our model is comprised of an effective
two-component Bose-Einstein condensate, driven by two classical pump lasers and
coupled to a single dynamic mode of a linear cavity in a double $\Lambda$
scheme. Cavity photons mediate the long-range spin-spin interactions with
spatially modulated coupling coefficients, where the latter ones can be tuned
by modifying spatial profiles of the pump lasers. As experimentally relevant
examples, we demonstrate that by properly choosing the spatial profiles of the
pump lasers achiral domain-wall antiferromagnetic and chiral spin-spiral orders
emerge beyond critical laser strengths. The transition between these two phases
can be observed in a single experimental setup by tuning the reflectivity of a
mirror. We also discuss extensions of our scheme for the implementation of
other classes of spin Hamiltonians.
