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

Add additionalCargoLock argument #328

Merged
merged 2 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ Note that you shouldn't call `overrideAttrs` on a derivation built by Naersk
| `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` |
| `additionalCargoLock` | Additional cargo lock used to specify crates required for build |
| `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" ]` |
Expand Down
11 changes: 10 additions & 1 deletion 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;

# Additional cargo lock used to specify crates required for build
additionalCargoLock = attrs0.additionalCargoLock or null;

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

Expand Down Expand Up @@ -317,7 +320,7 @@ let
# version and sha256 of the crate
# Example:
# [ { name = "wabt", version = "2.0.6", sha256 = "..." } ]
cratesIoDependencies = libb.mkVersions buildPlanConfig.cargolock;
cratesIoDependencies = libb.mkVersions buildPlanConfig.cargolock ++ lib.optionals (! isNull buildPlanConfig.additionalcargolock) (libb.mkVersions buildPlanConfig.additionalcargolock);

crateSpecificOverrides = import ./crate_specific.nix { inherit pkgs; };
};
Expand Down Expand Up @@ -408,6 +411,12 @@ let
else
throw "Naersk requires Cargo.lock to be available in root. Check that it is not in .gitignore and stage it when using git to filter sources (which flakes does)";

additionalcargolock =
if ! isNull attrs.additionalCargoLock then
readTOML (attrs.additionalCargoLock)
else
null;

packageName =
if ! isNull attrs.name
then attrs.name
Expand Down
Loading