However I don’t think anything using BuildKit is as fine grained as Bazel.
I have another thing in hof that is closer to this, also CUE + Dagger
https://github.com/hofstadter-io/hof/tree/_next/examples/env
https://github.com/hofstadter-io/hof/tree/_next/lib/env
I'm gearing up for a major rewrite into a new project, based on a bunch of learning and a desire to remove a ton of cruft that accumulated over 10+ years. I still debate if I want to wrap existing tools (tf, helm, etc...) or go for a full sail replacement. Dagger handles a lot of the tooling earlier in the CI process, mainly thinking CD here. Argo-* is our bain lately...
You might find the code gen aspects of hof interesting, I opted for Go's text/template, which you can also use from CUE if you wanted to have more literate (imo) code gen in your project.