A spectral shape optimization problem with a nonlocal competing term