Skip to content

Repository files navigation

C++ Bazel Rules with Nix Toolchain Example

This repository demonstrates how to use Nix to provide a C++ toolchain for Bazel builds.

Setup

  1. Enter the development shell:

    nix-shell
  2. Build the toolchain and example:

    # First build the toolchain
    bazel build @nix_toolchain_defs
    
    # Then build the example
    cd example
    bazel build //:hello
  3. Run the example:

    bazel run //:hello

Structure

  • nix_toolchain_defs.nix: Defines the Nix derivation that generates the Bazel rules
  • toolchain/: Contains the Bazel toolchain definition
  • example/: A simple example project using the toolchain
  • shell.nix: Development environment with all required dependencies

Troubleshooting

If you encounter issues with the toolchain, verify that:

  1. The nix_toolchain_defs.nix file outputs a directory (not a single file)
  2. The toolchain registration in WORKSPACE is correct
  3. All required dependencies are available in the shell environment

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages