Igneous rocks are formed from the cooling and crystallizing of magma, which is a hot liquid made of melted minerals., while metamorphic rocks are created by the heat and pressure from the Earth's interior, and sedimentary rocks are formed from the pressure.
Therefore, we would say the the internal heat in the Earth is responsible for the formation of the igneous and metamorphic rocks. While energy that drives the formation of sedimentary rocks comes from the sun.