Skip to content

Commit

Permalink
cratesDownloadUrl
Browse files Browse the repository at this point in the history
  • Loading branch information
Frarese authored and Patryk27 committed Jun 27, 2023
1 parent 8507af0 commit df10963
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ process, rest is passed-through into `mkDerivation`.
| `root` | Used by `naersk` to read the `Cargo.toml` and `Cargo.lock` files. May be different from `src`. When `src` is not set, `root` is (indirectly) used as `src`. |
| `gitAllRefs` | Whether to fetch all refs while fetching Git dependencies. Useful if the wanted revision isn't in the default branch. Requires Nix 2.4+. Default: `false` |
| `gitSubmodules` | Whether to fetch submodules while fetching Git dependencies. Requires Nix 2.4+. Default: `false` |
| `cratesDownloadUrl` | Url for downloading crates from an alternative source Default: `"https://crates.io"` |
| `cargoBuild` | The command to use for the build. The argument must be a function modifying the default value. <br/> Default: `''cargo $cargo_options build $cargo_build_options >> $cargo_build_output_json''` |
| `cargoBuildOptions` | Options passed to cargo build, i.e. `cargo build <OPTS>`. These options can be accessed during the build through the environment variable `cargo_build_options`. <br/> Note: naersk relies on the `--out-dir out` option and the `--message-format` option. The `$cargo_message_format` variable is set based on the cargo version.<br/> Note: these values are not (shell) escaped, meaning that you can use environment variables but must be careful when introducing e.g. spaces. <br/> The argument must be a function modifying the default value. <br/> Default: `[ "$cargo_release" ''-j "$NIX_BUILD_CORES"'' "--message-format=$cargo_message_format" ]` |
| `remapPathPrefix` | When `true`, rustc remaps the (`/nix/store`) source paths to `/sources` to reduce the number of dependencies in the closure. Default: `true` |
Expand Down
4 changes: 3 additions & 1 deletion build.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{ src
#| From where the crates should be downloaded
, cratesDownloadUrl
#| What command to run during the build phase
, cargoCommand
, cargoBuildOptions
Expand Down Expand Up @@ -389,7 +391,7 @@ let
crate = fetchurl {
inherit sha256;

url = "https://crates.io/api/v1/crates/${name}/${version}/download";
url = "${cratesDownloadUrl}/api/v1/crates/${name}/${version}/download";
name = "download-${name}-${version}";
};

Expand Down
4 changes: 4 additions & 0 deletions config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ let
# 2.4+.
gitSubmodules = attrs0.gitSubmodules or false;

# Url for downloading crates from an alternative source
cratesDownloadUrl = attrs0.cratesDownloadUrl or "https://crates.io";

# The command to use for the build.
cargoBuild =
allowFun attrs0 "cargoBuild"
Expand Down Expand Up @@ -259,6 +262,7 @@ let
cargoOptions
compressTarget
mode
cratesDownloadUrl

cargoBuildOptions
remapPathPrefix
Expand Down

0 comments on commit df10963

Please sign in to comment.