We derive a large deviation principle for random permutations induced by probability measures of the unit square, called *permutons*. These permutations are called μ-random permutations. We also introduce and study a new general class of models of random permutations, called *Gibbs permutation models*, which combines and generalizes μ-random permutations and the celebrated *Mallows model* for permutations. Most of our results hold in the general setting of Gibbs permutation models.

We apply the tools that we develop to the case of μ-random permutations conditioned to have an atypical proportion of patterns. Several results are made more concrete in the specific case of inversions. For instance, we prove the existence of at least one phase transition for a generalized version of the Mallows model where the base measure is non-uniform. This is in contrast with the results of Starr (2009, 2018) on the (standard) Mallows model, where the absence of phase transition, i.e., phase uniqueness, was proven.

Our results naturally lead us to investigate a new notion of permutons, called *conditionally constant permutons*, which generalizes both pattern-avoiding and pattern-packing permutons. We describe some properties of conditionally constant permutons with respect to inversions. The study of conditionally constant permutons for general patterns seems to be a challenging problem.