buildRustPackage: make cargoDeps logic easier to follow

The old logic flow had the structure

  if ( … ) {
    if ( … ) {
      …
    } else {
      …
    }
  } else {
    …
  }

which is quite hard to follow in Nix. Instead we ensure that no if
expression is inside a then branch.

This change is zero rebuild, as no logic was changed.
main
sternenseemann 2 years ago committed by zowoq
parent 39936c75c5
commit 357da6c296
  1. 7
      pkgs/build-support/rust/build-rust-package/default.nix

@ -59,8 +59,8 @@ assert buildType == "release" || buildType == "debug";
let let
cargoDeps = cargoDeps =
if cargoVendorDir == null if cargoVendorDir != null then null
then if cargoLock != null then importCargoLock cargoLock else if cargoLock != null then importCargoLock cargoLock
else fetchCargoTarball ({ else fetchCargoTarball ({
inherit src srcs sourceRoot unpackPhase cargoUpdateHook; inherit src srcs sourceRoot unpackPhase cargoUpdateHook;
name = cargoDepsName; name = cargoDepsName;
@ -69,8 +69,7 @@ let
hash = args.cargoHash; hash = args.cargoHash;
} // lib.optionalAttrs (args ? cargoSha256) { } // lib.optionalAttrs (args ? cargoSha256) {
sha256 = args.cargoSha256; sha256 = args.cargoSha256;
} // depsExtraArgs) } // depsExtraArgs);
else null;
# If we have a cargoSha256 fixed-output derivation, validate it at build time # If we have a cargoSha256 fixed-output derivation, validate it at build time
# against the src fixed-output derivation to check consistency. # against the src fixed-output derivation to check consistency.

Loading…
Cancel
Save