diff --git a/testing/rust/MODULE.bazel b/testing/rust/MODULE.bazel index 4a40978a..01dd0e78 100644 --- a/testing/rust/MODULE.bazel +++ b/testing/rust/MODULE.bazel @@ -43,7 +43,7 @@ rust.toolchain( non_module_deps = use_extension("//:non_module_deps.bzl", "non_module_deps") use_repo(non_module_deps, "nixpkgs") use_repo(non_module_deps, "nixpkgs_config_rust_toolchain") -register_toolchains("@nixpkgs_config_rust_toolchain//:rust_nix") +register_toolchains("@nixpkgs_config_rust_toolchain//:all") use_repo(non_module_deps, "nixpkgs_config_cc") use_repo(non_module_deps, "nixpkgs_config_cc_info") diff --git a/toolchains/rust/README.md b/toolchains/rust/README.md index 4afe22eb..9dafab93 100644 --- a/toolchains/rust/README.md +++ b/toolchains/rust/README.md @@ -2,7 +2,7 @@ -Rules for importing a Rust toolchain from Nixpkgs. +Rules for importing a Rust and rustfmt toolchain from Nixpkgs. # Rules diff --git a/toolchains/rust/rust.bzl b/toolchains/rust/rust.bzl index f8716955..9bb39c16 100644 --- a/toolchains/rust/rust.bzl +++ b/toolchains/rust/rust.bzl @@ -1,6 +1,6 @@ """ -Rules for importing a Rust toolchain from Nixpkgs. +Rules for importing a Rust and rustfmt toolchain from Nixpkgs. # Rules @@ -108,7 +108,7 @@ pkgs.buildEnv {{ visibility = ["//visibility:public"], ) - load('@rules_rust//rust:toolchain.bzl', 'rust_toolchain') + load('@rules_rust//rust:toolchain.bzl', 'rust_toolchain', 'rustfmt_toolchain') rust_toolchain( name = "rust_nix_impl", rust_doc = ":rust_doc", @@ -127,6 +127,12 @@ pkgs.buildEnv {{ stdlib_linkflags = {stdlib_linkflags}, visibility = ["//visibility:public"], ) + + rustfmt_toolchain( + name = "rustfmt_nix_impl", + rustfmt = ":rustfmt", + visibility = ["//visibility:public"], + ) EOF ''; }} @@ -140,6 +146,14 @@ toolchain( exec_compatible_with = {exec_constraints}, target_compatible_with = {target_constraints}, ) + +toolchain( + name = "rustfmt_nix", + toolchain = "@{toolchain_repo}//:rustfmt_nix_impl", + toolchain_type = "@rules_rust//rust/rustfmt:toolchain_type", + exec_compatible_with = {exec_constraints}, + target_compatible_with = {target_constraints}, +) """ def _nixpkgs_rust_toolchain_impl(repository_ctx):