Have you looked at Spack (https://github.com/spack/spack)? Disclaimer: I lead the project.
Spack essentially is nix with dependency resolution. spack packages can have conditional (nearly) anything: versions, options, compiler choices, dependencies (including virtual deps). The resolver can make choices about all of those.
See here for more details: https://arxiv.org/abs/2210.08404