We extend the nested sampling algorithm to simulate materials under periodic boundary and constant pressure conditions, and show how it can be used to determine the complete equilibrium phase diagram, for a given potential energy function, efficiently and in a highly automated fashion. The only inputs required are the composition and the desired pressure and temperature ranges, in particular, solid-solid phase transitions are recovered without any a priori knowledge about the structure of solid phases. We benchmark and showcase the algorithm on the periodic Lennard-Jones system, aluminium and NiTi.