Added `cargo_config` attribute to `cargo_bootstrap_repository`. (#2986)

This can be useful for workspaces which have a `config.toml` for the
workspace (used by `crate_universe`) and want to share the same
configuration with any bootstrap repositories.
diff --git a/cargo/private/cargo_bootstrap.bzl b/cargo/private/cargo_bootstrap.bzl
index beaac8a..b634aa3 100644
--- a/cargo/private/cargo_bootstrap.bzl
+++ b/cargo/private/cargo_bootstrap.bzl
@@ -27,6 +27,7 @@
         rustc_bin,
         binary,
         cargo_manifest,
+        cargo_config = None,
         environment = {},
         quiet = False,
         build_mode = "release",
@@ -40,6 +41,7 @@
         rustc_bin (path): The path to a Rustc binary.
         binary (str): The binary to build (the `--bin` parameter for Cargo).
         cargo_manifest (path): The path to a Cargo manifest (Cargo.toml file).
+        cargo_config (path, optional): The path to a Cargo configuration file (Config.toml) to use.
         environment (dict): Environment variables to use during execution.
         quiet (bool, optional): Whether or not to print output from the Cargo command.
         build_mode (str, optional): The build mode to use
@@ -54,6 +56,9 @@
     if not target_dir:
         target_dir = repository_ctx.path(".")
 
+    if cargo_config:
+        repository_ctx.symlink(cargo_config, repository_ctx.path(".cargo/config.toml"))
+
     args = [
         cargo_bin,
         "build",
@@ -173,6 +178,9 @@
     repository_ctx.path(repository_ctx.attr.cargo_lockfile)
     repository_ctx.path(repository_ctx.attr.cargo_toml)
 
+    if repository_ctx.attr.cargo_config:
+        repository_ctx.path(repository_ctx.attr.cargo_config)
+
 def _cargo_bootstrap_repository_impl(repository_ctx):
     # Pretend to Bazel that this rule's input files have been used, so that it will re-run the rule if they change.
     _detect_changes(repository_ctx)
@@ -203,10 +211,15 @@
     # be gathered.
     environment = dict(_collect_environ(repository_ctx, "*").items() + _collect_environ(repository_ctx, host_triple.str).items())
 
+    cargo_config = None
+    if repository_ctx.attr.cargo_config:
+        cargo_config = repository_ctx.path(repository_ctx.attr.cargo_config)
+
     built_binary = cargo_bootstrap(
         repository_ctx = repository_ctx,
         cargo_bin = repository_ctx.path(tools.cargo),
         rustc_bin = repository_ctx.path(tools.rustc),
+        cargo_config = cargo_config,
         binary = binary_name,
         cargo_manifest = repository_ctx.path(repository_ctx.attr.cargo_toml),
         build_mode = repository_ctx.attr.build_mode,
@@ -237,13 +250,17 @@
             ],
             default = "release",
         ),
+        "cargo_config": attr.label(
+            doc = "The path of the Cargo configuration (`Config.toml`) file.",
+            allow_single_file = True,
+        ),
         "cargo_lockfile": attr.label(
             doc = "The lockfile of the crate_universe resolver",
             allow_single_file = ["Cargo.lock"],
             mandatory = True,
         ),
         "cargo_toml": attr.label(
-            doc = "The path of the crate_universe resolver manifest (`Cargo.toml` file)",
+            doc = "The path of the `Cargo.toml` file.",
             allow_single_file = ["Cargo.toml"],
             mandatory = True,
         ),
diff --git a/crate_universe/deps_bootstrap.bzl b/crate_universe/deps_bootstrap.bzl
index e4fda6d..615b42b 100644
--- a/crate_universe/deps_bootstrap.bzl
+++ b/crate_universe/deps_bootstrap.bzl
@@ -1,5 +1,6 @@
 """A module is used to assist in bootstrapping cargo-bazel"""
 
+load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
 load("//cargo:defs.bzl", "cargo_bootstrap_repository")
 load("//crate_universe/private:srcs.bzl", "CARGO_BAZEL_SRCS")
 
@@ -14,7 +15,9 @@
         rust_version (str, optional): The rust version to use. Defaults to the default of `cargo_bootstrap_repository`.
         **kwargs: kwargs to pass through to cargo_bootstrap_repository.
     """
-    cargo_bootstrap_repository(
+
+    maybe(
+        cargo_bootstrap_repository,
         name = name,
         srcs = CARGO_BAZEL_SRCS,
         binary = "cargo-bazel",
diff --git a/docs/src/cargo.md b/docs/src/cargo.md
index 39624a1..72b58ac 100644
--- a/docs/src/cargo.md
+++ b/docs/src/cargo.md
@@ -178,8 +178,8 @@
 ## cargo_bootstrap_repository
 
 <pre>
-cargo_bootstrap_repository(<a href="#cargo_bootstrap_repository-name">name</a>, <a href="#cargo_bootstrap_repository-srcs">srcs</a>, <a href="#cargo_bootstrap_repository-binary">binary</a>, <a href="#cargo_bootstrap_repository-build_mode">build_mode</a>, <a href="#cargo_bootstrap_repository-cargo_lockfile">cargo_lockfile</a>, <a href="#cargo_bootstrap_repository-cargo_toml">cargo_toml</a>, <a href="#cargo_bootstrap_repository-env">env</a>,
-                           <a href="#cargo_bootstrap_repository-env_label">env_label</a>, <a href="#cargo_bootstrap_repository-repo_mapping">repo_mapping</a>, <a href="#cargo_bootstrap_repository-rust_toolchain_cargo_template">rust_toolchain_cargo_template</a>,
+cargo_bootstrap_repository(<a href="#cargo_bootstrap_repository-name">name</a>, <a href="#cargo_bootstrap_repository-srcs">srcs</a>, <a href="#cargo_bootstrap_repository-binary">binary</a>, <a href="#cargo_bootstrap_repository-build_mode">build_mode</a>, <a href="#cargo_bootstrap_repository-cargo_config">cargo_config</a>, <a href="#cargo_bootstrap_repository-cargo_lockfile">cargo_lockfile</a>, <a href="#cargo_bootstrap_repository-cargo_toml">cargo_toml</a>,
+                           <a href="#cargo_bootstrap_repository-env">env</a>, <a href="#cargo_bootstrap_repository-env_label">env_label</a>, <a href="#cargo_bootstrap_repository-repo_mapping">repo_mapping</a>, <a href="#cargo_bootstrap_repository-rust_toolchain_cargo_template">rust_toolchain_cargo_template</a>,
                            <a href="#cargo_bootstrap_repository-rust_toolchain_rustc_template">rust_toolchain_rustc_template</a>, <a href="#cargo_bootstrap_repository-timeout">timeout</a>, <a href="#cargo_bootstrap_repository-version">version</a>)
 </pre>
 
@@ -194,8 +194,9 @@
 | <a id="cargo_bootstrap_repository-srcs"></a>srcs |  Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
 | <a id="cargo_bootstrap_repository-binary"></a>binary |  The binary to build (the `--bin` parameter for Cargo). If left empty, the repository name will be used.   | String | optional |  `""`  |
 | <a id="cargo_bootstrap_repository-build_mode"></a>build_mode |  The build mode the binary should be built with   | String | optional |  `"release"`  |
+| <a id="cargo_bootstrap_repository-cargo_config"></a>cargo_config |  The path of the Cargo configuration (`Config.toml`) file.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
 | <a id="cargo_bootstrap_repository-cargo_lockfile"></a>cargo_lockfile |  The lockfile of the crate_universe resolver   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
-| <a id="cargo_bootstrap_repository-cargo_toml"></a>cargo_toml |  The path of the crate_universe resolver manifest (`Cargo.toml` file)   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="cargo_bootstrap_repository-cargo_toml"></a>cargo_toml |  The path of the `Cargo.toml` file.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
 | <a id="cargo_bootstrap_repository-env"></a>env |  A mapping of platform triple to a set of environment variables. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple `*` applies to all platforms.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
 | <a id="cargo_bootstrap_repository-env_label"></a>env_label |  A mapping of platform triple to a set of environment variables. This attribute differs from `env` in that all variables passed here must be fully qualified labels of files. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple `*` applies to all platforms.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
 | <a id="cargo_bootstrap_repository-repo_mapping"></a>repo_mapping |  In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function).   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  |
diff --git a/docs/src/flatten.md b/docs/src/flatten.md
index c0da9ea..c161899 100644
--- a/docs/src/flatten.md
+++ b/docs/src/flatten.md
@@ -2215,8 +2215,8 @@
 ## cargo_bootstrap_repository
 
 <pre>
-cargo_bootstrap_repository(<a href="#cargo_bootstrap_repository-name">name</a>, <a href="#cargo_bootstrap_repository-srcs">srcs</a>, <a href="#cargo_bootstrap_repository-binary">binary</a>, <a href="#cargo_bootstrap_repository-build_mode">build_mode</a>, <a href="#cargo_bootstrap_repository-cargo_lockfile">cargo_lockfile</a>, <a href="#cargo_bootstrap_repository-cargo_toml">cargo_toml</a>, <a href="#cargo_bootstrap_repository-env">env</a>,
-                           <a href="#cargo_bootstrap_repository-env_label">env_label</a>, <a href="#cargo_bootstrap_repository-repo_mapping">repo_mapping</a>, <a href="#cargo_bootstrap_repository-rust_toolchain_cargo_template">rust_toolchain_cargo_template</a>,
+cargo_bootstrap_repository(<a href="#cargo_bootstrap_repository-name">name</a>, <a href="#cargo_bootstrap_repository-srcs">srcs</a>, <a href="#cargo_bootstrap_repository-binary">binary</a>, <a href="#cargo_bootstrap_repository-build_mode">build_mode</a>, <a href="#cargo_bootstrap_repository-cargo_config">cargo_config</a>, <a href="#cargo_bootstrap_repository-cargo_lockfile">cargo_lockfile</a>, <a href="#cargo_bootstrap_repository-cargo_toml">cargo_toml</a>,
+                           <a href="#cargo_bootstrap_repository-env">env</a>, <a href="#cargo_bootstrap_repository-env_label">env_label</a>, <a href="#cargo_bootstrap_repository-repo_mapping">repo_mapping</a>, <a href="#cargo_bootstrap_repository-rust_toolchain_cargo_template">rust_toolchain_cargo_template</a>,
                            <a href="#cargo_bootstrap_repository-rust_toolchain_rustc_template">rust_toolchain_rustc_template</a>, <a href="#cargo_bootstrap_repository-timeout">timeout</a>, <a href="#cargo_bootstrap_repository-version">version</a>)
 </pre>
 
@@ -2231,8 +2231,9 @@
 | <a id="cargo_bootstrap_repository-srcs"></a>srcs |  Souce files of the crate to build. Passing source files here can be used to trigger rebuilds when changes are made   | <a href="https://bazel.build/concepts/labels">List of labels</a> | optional |  `[]`  |
 | <a id="cargo_bootstrap_repository-binary"></a>binary |  The binary to build (the `--bin` parameter for Cargo). If left empty, the repository name will be used.   | String | optional |  `""`  |
 | <a id="cargo_bootstrap_repository-build_mode"></a>build_mode |  The build mode the binary should be built with   | String | optional |  `"release"`  |
+| <a id="cargo_bootstrap_repository-cargo_config"></a>cargo_config |  The path of the Cargo configuration (`Config.toml`) file.   | <a href="https://bazel.build/concepts/labels">Label</a> | optional |  `None`  |
 | <a id="cargo_bootstrap_repository-cargo_lockfile"></a>cargo_lockfile |  The lockfile of the crate_universe resolver   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
-| <a id="cargo_bootstrap_repository-cargo_toml"></a>cargo_toml |  The path of the crate_universe resolver manifest (`Cargo.toml` file)   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
+| <a id="cargo_bootstrap_repository-cargo_toml"></a>cargo_toml |  The path of the `Cargo.toml` file.   | <a href="https://bazel.build/concepts/labels">Label</a> | required |  |
 | <a id="cargo_bootstrap_repository-env"></a>env |  A mapping of platform triple to a set of environment variables. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple `*` applies to all platforms.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
 | <a id="cargo_bootstrap_repository-env_label"></a>env_label |  A mapping of platform triple to a set of environment variables. This attribute differs from `env` in that all variables passed here must be fully qualified labels of files. See [cargo_env](#cargo_env) for usage details. Additionally, the platform triple `*` applies to all platforms.   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  `{}`  |
 | <a id="cargo_bootstrap_repository-repo_mapping"></a>repo_mapping |  In `WORKSPACE` context only: a dictionary from local repository name to global repository name. This allows controls over workspace dependency resolution for dependencies of this repository.<br><br>For example, an entry `"@foo": "@bar"` declares that, for any time this repository depends on `@foo` (such as a dependency on `@foo//some:target`, it should actually resolve that dependency within globally-declared `@bar` (`@bar//some:target`).<br><br>This attribute is _not_ supported in `MODULE.bazel` context (when invoking a repository rule inside a module extension's implementation function).   | <a href="https://bazel.build/rules/lib/dict">Dictionary: String -> String</a> | optional |  |