Setup
❄️ Prepare Nix
Install Nix and enable flake support. The new experimental nix installer does this for you: https://github.com/NixOS/experimental-nix-installer
Install direnv
and add the direnv hook
to your
.bashrc
:
Now clone rules_mojo
, cd
into it and run direnv allow
:
Inside the Nix environment you’ll have access to the mojo
command:
To test the mojo_toolchain
with Bazel, run the Mojo standard library test
suite:
To run the example in the examples
directory:
🚢 Building in Kubernetes
You can test the remote execution capabilities of rules_mojo
by spinning up
the builtin Kubernetes cluster with a pre-configured NativeLink setup.
Make sure you have a recent version of Docker installed. Then you can invoke the following command from within the Nix flake:
This spins up a local kind cluster, builds a Mojo remote execution container and deploys it into a NativeLink remote execution setup.
The setup may take a minute to boot up. When running the command the first time it might take some time to build NativeLink from source inside the cluster pipelines. Once the command finishes you can invoke the following command to run a local dashboard:
Visit http://localhost:8080/?namespace=default to view the cluster topology.
To now point Bazel invocations to this cluster, invoke lre-bazel
instead of
bazel
:
This sends build invocations to the cluster instead of building locally on your own machine.
To delete the cluster, run:
🌱 Use in external projects
See the templates/default
directory for templates. To start an entirely new
project: