Using Bzlmod
Add to your MODULE.bazel file:
bazel_dep(name = "bazel_lib", version = "3.0.0")Using WORKSPACE (deprecated)
Paste this snippet into your WORKSPACE file:
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
http_archive(
name = "bazel_lib",
sha256 = "6fd3b1e1a38ca744f9664be4627ced80895c7d2ee353891c172f1ab61309c933",
strip_prefix = "bazel-lib-3.0.0",
url = "https://github.com/bazel-contrib/bazel-lib/releases/download/v3.0.0/bazel-lib-v3.0.0.tar.gz",
)
load("@bazel_lib//lib:repositories.bzl", "bazel_lib_dependencies", "bazel_lib_register_toolchains")
# Required bazel-lib dependencies
bazel_lib_dependencies()
# Required rules_shell dependencies
load("@rules_shell//shell:repositories.bzl", "rules_shell_dependencies", "rules_shell_toolchains")
rules_shell_dependencies()
rules_shell_toolchains()
# Register bazel-lib toolchains
bazel_lib_register_toolchains()
# Create the host platform repository transitively required by bazel-lib
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
load("@platforms//host:extension.bzl", "host_platform_repo")
maybe(
host_platform_repo,
name = "host_platform",
)