This repository demonstrates how to use Nix to provide a C++ toolchain for Bazel builds.
-
Enter the development shell:
nix-shell
-
Build the toolchain and example:
# First build the toolchain bazel build @nix_toolchain_defs # Then build the example cd example bazel build //:hello
-
Run the example:
bazel run //:hello
nix_toolchain_defs.nix: Defines the Nix derivation that generates the Bazel rulestoolchain/: Contains the Bazel toolchain definitionexample/: A simple example project using the toolchainshell.nix: Development environment with all required dependencies
If you encounter issues with the toolchain, verify that:
- The
nix_toolchain_defs.nixfile outputs a directory (not a single file) - The toolchain registration in WORKSPACE is correct
- All required dependencies are available in the shell environment