Eco-evolutionary dynamics of nested Darwinian populations and the emergence of community-level heredity