(entirely serious, this is how you do it, last tested July 8, 2023)
Summary: you can use nixpkgs's bazel_6 to build and run CockroachDB's bazelbuilder Docker container, which will use the bazel version it really wants to use for building cockroach. You need to patchelf a few things along the way, and then patchelf the resulting cockroach binary.
- Add this to your NixOS configuration: