11"""<!-- Edit the docstring in `toolchains/rust/rust.bzl` and run `bazel run //docs:update-README.md` to change this repository's `README.md`. -->
22
3- Rules for importing a Rust toolchain from Nixpkgs.
3+ Rules for importing a Rust and rustfmt toolchain from Nixpkgs.
44
55# Rules
66
@@ -108,7 +108,7 @@ pkgs.buildEnv {{
108108 visibility = ["//visibility:public"],
109109 )
110110
111- load('@rules_rust//rust:toolchain.bzl', 'rust_toolchain')
111+ load('@rules_rust//rust:toolchain.bzl', 'rust_toolchain', 'rustfmt_toolchain' )
112112 rust_toolchain(
113113 name = "rust_nix_impl",
114114 rust_doc = ":rust_doc",
@@ -127,6 +127,12 @@ pkgs.buildEnv {{
127127 stdlib_linkflags = {stdlib_linkflags},
128128 visibility = ["//visibility:public"],
129129 )
130+
131+ rustfmt_toolchain(
132+ name = "rustfmt_nix_impl",
133+ rustfmt = ":rustfmt",
134+ visibility = ["//visibility:public"],
135+ )
130136 EOF
131137 '';
132138}}
@@ -140,6 +146,14 @@ toolchain(
140146 exec_compatible_with = {exec_constraints},
141147 target_compatible_with = {target_constraints},
142148)
149+
150+ toolchain(
151+ name = "rustfmt_nix",
152+ toolchain = "@{toolchain_repo}//:rustfmt_nix_impl",
153+ toolchain_type = "@rules_rust//rust/rustfmt:toolchain_type",
154+ exec_compatible_with = {exec_constraints},
155+ target_compatible_with = {target_constraints},
156+ )
143157"""
144158
145159def _nixpkgs_rust_toolchain_impl (repository_ctx ):
0 commit comments