Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

registryFromSparse: add missing API docs #710

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 44 additions & 2 deletions docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,9 @@ newLib = craneLib.appendCrateRegistries [

# Or even
(lib.registryFromSparse {
url = "https://index.crates.io/";
sha256 = "d16740883624df970adac38c70e35cf077a2a105faa3862f8f99a65da96b14a3";
indexUrl = "https://index.crates.io/config.json";
configSha256 = "1cxgzdm1ipqmgwnq7kgym92axna7pfyhgfla63vl7dvydwn3m52v";
fetchurlExtraArgs = {};
})
];
```
Expand Down Expand Up @@ -1382,6 +1383,47 @@ craneLib.registryFromGitIndex {
# }
```

### `craneLib.registryFromSparse`

`registryFromSparse :: set -> set`

Prepares a (sparse) crate registry into a format that can be passed directly to
`appendCrateRegistries` using the registry's download URL.

If the registry in question has a stable download URL (which either never
changes, or it does so very infrequently), then `registryFromDownloadUrl` is a
great and lightweight choice for including the registry. To get started,
download the registry's `config.json` and copy the value of the `dl` entry.

If the registry's download endpoint changes more frequently and you would like
to infer the configuration directly from a git revision, consider using
`registryFromGitIndex` as an alternative.

If the registry needs a special way of accessing crate sources the
`fetchurlExtraArgs` set can be used to influence the behavior of fetching the
crate sources (e.g. by setting `curlOptsList`)

#### Required attributes
* `indexUrl`: an HTTP URL to the registry's config.json
* `configSha256`: a sha256 hash of the contents of config.json

#### Optional attributes
* `fetchurlExtraArgs`: a set of arguments which will be passed on to the
`fetchurl` for each crate being sourced from this registry

```nix
craneLib.registryFromSparse {
indexUrl = "https://index.crates.io/config.json";
configSha256 = "1cxgzdm1ipqmgwnq7kgym92axna7pfyhgfla63vl7dvydwn3m52v";
}
# {
# "sparse+https://index.crates.io/config.json/" = {
# downloadUrl = "https://static.crates.io/crates/{crate}/{version}/download";
# fetchurlExtraArgs = { };
# };
# }
```

### `craneLib.urlForCargoPackage`

`urlForCargoPackage :: set -> set`
Expand Down