In principle it should be possible to build Bazel from source on macOS. Bazel itself is quite a mess to patch, since xcrun is sometimes invoked from the PATH, sometimes absolutely from /usr/bin, and sometimes via an xcrunwrapper.sh script.
What has me stumped is that Bazel grabs a bunch of dependencies whose build systems also rely on xcrun, particularly protobuf and grpc. Many of the calls don't straightforwardly do something like /usr/bin/xcrun clang ..., but instead query various SDK locations and feed them into further wrapper scripts. Unfortunately the only success I've had has been allowing these build systems access to /usr/bin/xcrun. For my use case an impure-but-working Bazel derivation on Darwin is better than no working Bazel derivation on Darwin, especially considering that the impurity is confined to Xcode's CLT and libraries. From what I understand there are two reasonable paths forward.
Accept this impurity on Darwin, but do so in a principled way. Surely there's some existing idiomatic way of doing this. I've seen mention of a "pure Darwin stdenv" and an "impure Darwin stdenv" in discussions elsewhere, but I can't seem to find any documentation on these.
Build some heavyweight hacks into the Bazel build system. This might be something like inserting extra machinery to patch the external dependencies that Bazel grabs, or perhaps writing a fake xcrun command. I think this would involve a lot of work for questionable benefit; because of Xcode it seems that larger degree of impurity tends to be acceptable when it comes to Darwin in Nixpkgs at large.
@copumpkin and @abbradar, I'm curious about your thoughts.
Regrettably, I'm tied to Bazel because of TensorFlow. Furthermore, I'm calling TF from C++ (already a use case poorly supported upstream), for which none of upstream's binary distributions are suitable given my hardware, so I must build TF from source. It's only due to Nix that deploying this monstrosity works at all. A while ago there were a few community supported alternative build systems for TF, but they've all diverged too much for my use case. A working Bazel derivation on macOS would allow my colleagues to build our application and run tests locally without a virtual machine.
It is indeed a shame that the "state of the art" in machine learning is in such a pitiful state.
For what it is worth, williammpratt's attitude here is not representative of the NixOS community's attitude toward other software. The user has since been blocked from the NixOS organization.
Probably a duplicate of #30590
Can these issues be merged?
Closing this issue in favor of #30590.
Most helpful comment
For what it is worth, williammpratt's attitude here is not representative of the NixOS community's attitude toward other software. The user has since been blocked from the NixOS organization.