At some level all fossil fuels come from the sun. Fossil fuels come from biomass accumulated over millions of years. The energy that went into gathering all that carbon and hydrocarbons came from the sun.
Take it a step further and nearly all our energy comes from nuclear fusion, with the exceptions you noted.