Just a voltage regulator with a series diode at the output to the battery. The solar cell maximum current will act as a current limiter.
For NiMH, use six cells and set the voltage at full charge to around 8.7 - 9V
For lithium, you would need a two cell combined protection and balance module connected between the cells and everything else. Do not use internally protected cells with those.
Use a solar cell panel just big enough to prevent the device shutting off from low voltage; with a simple system like this, the batteries should occasionally reach full charge, but not be held there continuously. Setting it up so the cells partly discharge frequently will give the longest cell life.
(Ideally, they should charge with current monitoring to100%, then the charge shut off until they are down to around 20%, then charge again. Using a barely large enough cell should allow some cycling and avoid them being held at full charge, which can wreck them quickly).
NiMH are really better for a minimal system such as this. They can be held at full charge just about forever, as long as the voltage is not too high.