Classic ecological theory explains species coexistence in variable environments. While spatial variation is often treated as an intrinsic feature of a landscape, it may be shaped and even generated by the resident community. All species modify their local environment to some extent, driving changes that can feed back to affect the composition and coexistence of the community, potentially over timescales very different from population dynamics. We introduce a simple nested modeling framework for community dynamics in heterogeneous environments, including the possible evolution of heterogeneity over time due to community-environment feedbacks. We use this model to derive analytical conditions for species coexistence in environments where heterogeneity is either fixed or shaped by feedbacks. Among other results, our approach reveals how dispersal and environmental specialization interact to shape realized patterns of habitat association and demonstrates that environmental feedbacks can tune landscape conditions to allow the stable coexistence of any number of species. Our flexible modeling framework helps explain feedback dynamics that arise in a wide range of ecosystems and offers a generic platform for exploring the interplay between species and landscape diversity.