Desert soils harbour diverse communities of aerobic bacteria despite lacking substantial organic carbon inputs from vegetation. A major question is therefore how these communities maintain their biodiversity and biomass in these resource-limiting ecosystems. Here, we investigated desert topsoils and biological soil crusts collected along an aridity gradient traversing four climatic regions (sub-humid, semi-arid, arid, and hyper-arid). Metagenomic analysis indicated these communities vary in their capacity to use sunlight, organic compounds, and inorganic compounds as energy sources. Thermoleophilia, Actinobacteria, and Acidimicrobiia were the most abundant and prevalent bacterial classes across the aridity gradient in both topsoils and biocrusts. Contrary to the classical view that these taxa are obligate organoheterotrophs, genome-resolved analysis suggested they are metabolically flexible, with the capacity to also use atmospheric H2 to support aerobic respiration and often carbon fixation. In contrast, Cyanobacteria were patchily distributed and only abundant in certain biocrusts. Activity measurements profiled how aerobic H2 oxidation, chemosynthetic CO2 fixation, and photosynthesis varied with aridity. Cell-specific rates of atmospheric H2 consumption increased 143-fold along the aridity gradient, correlating with increased abundance of high-affinity hydrogenases. Photosynthetic and chemosynthetic primary production co-occurred throughout the gradient, with photosynthesis dominant in biocrusts and chemosynthesis dominant in arid and hyper-arid soils. Altogether, these findings suggest that the major bacterial lineages inhabiting hot deserts use different strategies for energy and carbon acquisition depending on resource availability. Moreover, they highlight the previously overlooked roles of Actinobacteriota as abundant primary producers and trace gases as critical energy sources supporting productivity and resilience of desert ecosystems.