First, you cannot any 5K iMac as a full video display with any Mac.
With that said, I personally would go for an MacMini Pro and a minimum of a 1 TB drive and as much RAM as you can possibly afford.
I say 512GB drive minimum because those apps can create very large caches, preview files, and databases that will consume lots of internal storage. This also assumes that you keep your photo libraries on an external drive and only keep work in progress files on the internal.
Through the years, for decent performance of Lightroom and Photoshop, I have found that 32 GB of RAM is a minimum for the combination of those apps to work well. As years go on, it only seems to be getting worse.
As a note, you need to make sure you get all of the above at time of purchase as the RAM and the drive are not user upgradable.
Finally, the reason for the Mini Pro is to get as much performance as you want. However, with the above suggestions, depending on the complexity of your work in Lightroom and Photoshop, you may be able to get by with just the M4 Mini and not the M4 Pro version.
Another consideration, once you add up all the options on a MacMini, you end up approaching or surpassing the new M4 MacStudio which has the M4 Max processor, faster bus speeds, faster internal SSD,etc.