Often needed little bits of
bazel knowledge that I tend to forget.
Use an alternate repository
This allows you to use an alternate source repository from the one declared in
WORKSPACE, or worse, in dependencies. You can use that to generate a quick patch, or to provide a fix to upstream.
user.bazelrc in your workspace root and add it to
.gitignore if you use git, so that it remains unique to you.
But, don’t forget that you have it.
Not sure why, but various
bazel rules don’t seem to be documented well. While there are examples, there’s minimal explanation on how rules work. And the way rules work changes substantially across rules releases.
To fix this, I made a small but complete example of using
rules_rust and its IDE integration via
See it at: http://github.com/filmil/rust-bazel-example, refer to
README.md for details.
Expand locations in a build rule
This expands any appearances of
$(location <label>) in deps.
Examples of some of the above https://github.com/filmil/bazel-bats/blob/main/rules.bzl#L69
Generate a file based on a template.
Release an archive with GitHub actions and Bazel
Here’s an example: https://github.com/filmil/bazoekt/blob/main/.github/workflows/release.yml