Add global cargo options to config

This commit is contained in:
Nicolas Mattia 2019-12-13 15:12:08 +01:00
parent 551a2a6339
commit b9310fdcf7
2 changed files with 7 additions and 2 deletions

View file

@ -37,6 +37,7 @@
, buildInputs
, builtDependencies
, release
, cargoOptions
, stdenv
, lib
, rsync
@ -104,6 +105,7 @@ let
configurePhase = ''
cargo_release=( ${lib.optionalString release "--release" } )
cargo_options=( ${lib.escapeShellArgs cargoOptions} )
runHook preConfigure

View file

@ -14,14 +14,16 @@ let
root = attrs0.root or null;
# The command to use for the build.
cargoBuild = attrs0.cargoBuild or
''cargo build "''${cargo_release}" -j $NIX_BUILD_CORES -Z unstable-options --out-dir out'';
''cargo "''${cargo_options[@]}" build "''${cargo_release[@]}" -j $NIX_BUILD_CORES -Z unstable-options --out-dir out'';
# When true, `checkPhase` is run.
doCheck = attrs0.doCheck or true;
# The commands to run in the `checkPhase`.
cargoTestCommands = attrs0.cargoTestCommands or
[ ''cargo test "''${cargo_release}" -j $NIX_BUILD_CORES'' ];
[ ''cargo "''${cargo_options[@]}" test "''${cargo_release[@]}" -j $NIX_BUILD_CORES'' ];
# Extra `buildInputs` to all derivations.
buildInputs = attrs0.buildInputs or [];
# Options passed to cargo before the command (cargo OPTIONS <cmd>)
cargoOptions = attrs0.cargoOptions or [];
# When true, `cargo doc` is run and a new output `doc` is generated.
doDoc = attrs0.doDoc or true;
# When true, all cargo builds are run with `--release`.
@ -109,6 +111,7 @@ let
buildConfig = {
compressTarget = attrs.compressTarget;
doCheck = attrs.doCheck;
cargoOptions = attrs.cargoOptions;
buildInputs = attrs.buildInputs;
removeReferencesToSrcFromDocs = attrs.removeReferencesToSrcFromDocs;
doDoc = attrs.doDoc;