Geothermal energy, ultimately, is derived from the Sun. How can that be? There's a couple of ways you could look at it.
First, models for planetary formation involve material ejected from primordial supernovae slowly coalescing under the force of gravity. Nearly all matter and energy trapped in the core of the Earth originated inside the Sun (not the same Sun, technically, since the current Sun formed out of that same supernova explosion the Earth came from).
Secondly, thermal energy is only useful when there is a temperature gradient. At the end of a thermal reaction (uniform temperature), the amount of energy in a system is the same, but no more meaningful work can be done with it. So the thermal energy in the Earth's core is only useful to us because of the relatively cooler surface temperature, and the surface temperature of a planet is directly attributable to the amount of solar energy it receives (among other things).
You could even argue that solar energy is nothing more than a side-effect of nuclear energy, the direct result of thermal energy released by nuclear fusion of lighter elements into heavier elements. But you can't argue that nuclear energy is the result of solar energy. It's kinda like how all squares are rectangles, but not all rectangles are squares.