Skip to content

Commit e1d1158

Browse files
authored
Merge pull request #625 from lucasbergman/rustfmt-toolchain
Add rustfmt_toolchain
2 parents 8fed658 + ae69710 commit e1d1158

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

testing/rust/MODULE.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ rust.toolchain(
4343
non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps")
4444
use_repo(non_module_deps, "nixpkgs")
4545
use_repo(non_module_deps, "nixpkgs_config_rust_toolchain")
46-
register_toolchains("@nixpkgs_config_rust_toolchain//:rust_nix")
46+
register_toolchains("@nixpkgs_config_rust_toolchain//:all")
4747

4848
use_repo(non_module_deps, "nixpkgs_config_cc")
4949
use_repo(non_module_deps, "nixpkgs_config_cc_info")

toolchains/rust/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<!-- Edit the docstring in `toolchains/rust/rust.bzl` and run `bazel run //docs:update-README.md` to change this repository's `README.md`. -->
44

5-
Rules for importing a Rust toolchain from Nixpkgs.
5+
Rules for importing a Rust and rustfmt toolchain from Nixpkgs.
66

77
# Rules
88

toolchains/rust/rust.bzl

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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

145159
def _nixpkgs_rust_toolchain_impl(repository_ctx):

0 commit comments

Comments
 (0)