For termux: install termux from fdroid and pkg install all the stuff you need. There's a couple of gotchas if you try to build stuff directly, but it mostly just works overall.
For full Linux with x11 GUI: follow the guide I linked.
For the keyboard setup, I just plug keyboard, mouse and monitor on a USB c dongle. I don't use android desktop mode personally.
My next device will likely be a foldable phone, with a foldable keyboard and a stand it works as a laptop in a pinch (otherwise dongle for kb/mouse/display)