Derrick’s theorem in curved spacetime