Since you talk about "collecting luggage", I'm assuming you have separate bookings for Sofia to Istanbul and Istanbul to London. (If you had a single booking, you wouldn't need to collect luggage, it would be automatically forwarded in Istanbul and you could stay in the transit lounge.)
According to Turkish authorities:
If you will not leave the transit lounge at the airport you are not
required to have transit visa. Otherwise, you have to make visa
application to the nearest Turkish Representation.
It sounds like you will have to leave the transit lounge in order to collect your luggage and check in to the new flight.
Nigerian citizens do need visas for Turkey. The source doesn't mention any exceptions for UK visa holders.
I have not found any information on where transit visas can be applied for for Turkey. All sites I have seen offer information only on tourist, business and e-visas.
The most convenient visa to get would perhaps be an e-visa.
There is a website to apply for e-visas for Turkey.