Announcing bazel_local_nix 0.1.0

May 28, 2026

I’m excited to announce the release of bazel_local_nix 0.1.0!

bazel_local_nix provides Bazel rules that make Nix packages available inside a Bazel workspace without a host-level Nix installation and without nix-portable.

What’s New?

Earlier versions of this project relied on shimming Bazel through a nix-portable nix-shell wrapper. That approach has been completely removed and replaced by a more robust rule set.

The new rules bootstrap an ephemeral Nix from the official binary release, run it unprivileged inside a bwrap (bubblewrap) user namespace against a persistent store, and expose the results as ordinary Bazel artifacts.

Key features include:

  • No host-provided bwrap required: The bwrap binary is fetched as a pinned, statically-linked release during bootstrap. All you need is the permission to create unprivileged user namespaces.
  • nix_package and nix_toolchain rules: Build Nix installables into relocatable bundles and extract them easily into directory trees for Bazel to use.
  • Nix-backed C/C++ Toolchain: A module extension turns a nixpkgs compiler into a registered Bazel cc_toolchain. This ensures that your C/C++ builds are perfectly reproducible and run under bwrap.

Requirements

  • Linux x86_64
  • Permission to create unprivileged user namespaces
  • bash, tar, xz, cp, flock, and coreutils
  • Network egress to releases.nixos.org and cache.nixos.org
  • Bazel with bzlmod

Getting Started

Note: This module is published in my personal Bazel registry. To use it, you must configure Bazel to pull from my registry by adding the following to your .bazelrc:

common --registry=https://raw.githubusercontent.com/filmil/bazel-registry/main
common --registry=https://bcr.bazel.build

Once configured, simply add rules_nix to your MODULE.bazel:

bazel_dep(name = "rules_nix", version = "0.1.0")

nix_bootstrap = use_repo_rule("@rules_nix//:nix_bootstrap.bzl", "nix_bootstrap")
nix_bootstrap(name = "nix_bootstrap")

Check out the GitHub repository for full documentation, integration examples, and usage instructions.

Happy building!

Acknowledgements and References

This project draws inspiration from the fantastic foundational concepts established by Tweag.io’s pioneering work on integrating Bazel and Nix, most notably with their rules_nixpkgs repository. bazel_local_nix provides an alternative approach tailored for environments where a host-level Nix installation isn’t feasible.