Simulating the interstellar medium of galaxies with radiative transfer, non-equilibrium thermochemistry, and dust