Using Sonatype Nexus Community Edition as a cargo proxy

  • Nexus 3.77+ supports cargo repository even in the CE edition. However, version 3.77 introduces a hard usage limit. Quick local setup:
docker run -d -p 8081:8081 --name nexus sonatype/nexus3
  • Assume a cargo-proxy repository was created with remote URL https://index.crates.io.

nexus

  • Add the following to .cargo/config.toml:
❯ cat .cargo/config.toml
[registries.nexus]
index = "sparse+http://localhost:8081/repository/cargo-proxy/"

[registry]
default = "nexus"

[source.crates-io]
replace-with = "nexus"

[source.nexus]
registry = "sparse+http://localhost:8081/repository/cargo-proxy/"

According to the docs on https://index.crates.io/, cargo uses the sparse protocol. Omitting the sparse+ prefix in config.toml will cause errors.

index_crates_io

  • Build:
❯ cargo build

References: