Tons of people pull the 5k iMac apart, gut the insides and install a driver board to run the screen. For a few hundred bucks you get a wicked 5k screen
For cables, my iMac had an opening in the back for RAM sticks, which I popped out and wired all cables through. I mounted the driver board on a piece of plexiglass so that most of the ports are accessible directly to the RAM opening. For power, I use a regular third party power brick I had laying around, though some people have reused the iMac’s original power cable with an internal power supply.
Honestly, the hardest parts were identifying the correct driver board and gluing the front glass back on after assembly.