https://en.wikipedia.org/wiki/Nitrogen_fixation
which is ultimately very energy intensive
If you think about the context in which we are operating though (desert with a lot of sunlight) it might be possible to colocate a solar powered reactor producing all the ammonia required for the hydroponic farms in the desert. This is just handwaving though: it seems like apart from electricity, the next biggest input is natural gas. While this may not be a problem in, say, Saudi Arabia, probably would be in Namibia.
https://en.wikipedia.org/wiki/Birkeland%E2%80%93Eyde_process
The stems and such are mostly water and a little bit of carbon, I guess other sources of nitrogen would have an excellent ROI (a modest amount of fertilizer vs high capital and labor costs).
The tomato plan contain mild toxic content, and is quite smelly so not even goats seem happy to eat it. Not sure what they actually do with composted tomato plants.