Cargo repositories use the sparse index (Cargo 1.70 and newer). The examples use the conventional names cargo-hosted and cargo-proxy.

Connecting

Describe the registry in ~/.cargo/config.toml; for repositories that require authentication, list the credential provider explicitly:

[registry]
global-credential-providers = ["cargo:token"]

[registries.galleon]
index = "sparse+https://<GALLEON_HOST>/repository/cargo-hosted/"

The token is a ready Basic <BASE64> string; store it with cargo login:

printf 'Basic <BASE64>\n' | cargo login --registry galleon

Proxy for crates.io

To route all public dependencies through Galleon, configure source replacement — the registry is also declared under [registries] so a token can be attached to it:

[registries.galleon-proxy]
index = "sparse+https://<GALLEON_HOST>/repository/cargo-proxy/"

[source.crates-io]
replace-with = "galleon-proxy"

[source.galleon-proxy]
registry = "sparse+https://<GALLEON_HOST>/repository/cargo-proxy/"

If the proxy repository requires authentication, store a token for it as well: cargo login --registry galleon-proxy (the same Basic <BASE64> string).

Usage

A dependency from the hosted registry is declared in Cargo.toml with the registry name:

mycrate = { version = "1", registry = "galleon" }

Publishing

A crate is sent to the hosted registry under the name declared in registries.galleon:

cargo publish --registry galleon

Specifics

Format specifics:

  • Re-publishing an existing version is rejected with 409; names are compared case-insensitively, with - and _ treated as the same character.
  • cargo yank is supported: the version is flagged in the index, but the file is not deleted — builds with the exact version in Cargo.lock keep working. The edit privilege is required.
  • cargo search and cargo owner are not supported.