  We prove a $C^{1,1}$ estimate for solutions of complex Monge-Amp\`ere
equations on compact K\"ahler manifolds with possibly nonempty boundary, in a
degenerate cohomology class. This strengthens previous estimates of
Phong-Sturm. As applications we deduce the local $C^{1,1}$ regularity of
geodesic rays in the space of K\"ahler metrics associated to a test
configuration, as well as the local $C^{1,1}$ regularity of quasi-psh envelopes
in nef and big classes away from the non-K\"ahler locus.
