nixos/bazelisk: add NixOS module; remove "does not work" warning#510826
Open
DhashS wants to merge 2 commits intoNixOS:masterfrom
Open
nixos/bazelisk: add NixOS module; remove "does not work" warning#510826DhashS wants to merge 2 commits intoNixOS:masterfrom
DhashS wants to merge 2 commits intoNixOS:masterfrom
Conversation
7a54175 to
b8203bd
Compare
409b98d to
0a3c520
Compare
Add a programs.bazelisk NixOS module that installs bazelisk with a bazel symlink, enables envfs for /bin/bash compatibility, and writes /etc/bazel.bazelrc with Nix store paths for common Bazel action tools. The module also supports optional CC/CXX settings for rules_cc detection, extra action PATH packages, and extra bazelrc lines. Add a NixOS test covering the generated bazelrc, envfs fallback, and bazel symlink, and link it from bazelisk.passthru.tests.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add a
programs.bazeliskNixOS module that makes bazelisk work on NixOS, and remove theBEWARE: This package does not work on NixOSwarning from the bazelisk package meta.Motivation
Bazelisk downloads unpatched Bazel binaries that fail on NixOS because:
/bin/bashdoesn't exist (or isn't resolvable with an emptyPATH)touch,grep, etc.) aren't at FHS-standard pathsrules_cctoolchain detection can't find a C compilerThe existing
bazel_9nix package solves this by building Bazel from source with 6+ patches, but that locks you to a single version. Bazelisk's whole purpose is version-switching via.bazelversion, which the patched package can't support.What the module does
programs.bazelisk.enable = truesets up three things:bazelsymlink so it's a drop-in replacementbashin the fallback path, so/bin/bashresolves even when Bazel strips the environment (exec env -)/etc/bazel.bazelrcwith--action_env=PATHand--host_action_env=PATHpointing to Nix store paths for common tools (bash, coreutils, findutils, gawk, gnugrep, gnused, gnutar, gzip, which, unzip)Optional
cc/cxxoptions set--repo_env=CC/CXXforrules_cctoolchain detection.extraPackagesandextraBazelrcallow further customization.Example usage
Per-project settings (e.g. extra rustc flags, pkg-config paths) still go in
.bazelrc.user.Testing
Tested on a real-world Bazel project with Rust, TypeScript, and Swift rules — 27/27 targets building on both Bazel 9.0.1 and 9.0.2 by simply changing
.bazelversionand letting bazelisk do its thing.Note: there's a companion fix needed in bazel_env.bzl to replace
touchwith a bash builtin in one of its actions, but all other Bazel rules work out of the box.Files changed
nixos/modules/programs/bazelisk.nix— new NixOS modulenixos/modules/module-list.nix— register the modulepkgs/by-name/ba/bazelisk/package.nix— update meta descriptionThis PR was vibe coded with Claude Code.