Commit 7609cbad authored by Yueh-Shun Li's avatar Yueh-Shun Li
Browse files

buildRustPackage: restructure with lib.extendMkDerivation

Support fixed-point arguments with lib.extendMkDerivation

Postpone formatting for more concise diff.
parent 016ba92a
Loading
Loading
Loading
Loading
+15 −11
Original line number Diff line number Diff line
@@ -18,6 +18,18 @@
  windows,
}:

lib.extendMkDerivation {
  constructDrv = stdenv.mkDerivation;

  excludeDrvArgNames = [
    "depsExtraArgs"
    "cargoUpdateHook"
    "cargoDeps"
    "cargoLock"
  ];

  extendDrvArgs =
    finalAttrs:
{
  name ? "${args.pname}-${args.version}",

@@ -119,15 +131,7 @@ let
  target = stdenv.hostPlatform.rust.rustcTargetSpec;
  targetIsJSON = lib.hasSuffix ".json" target;
in

stdenv.mkDerivation (
  (removeAttrs args [
    "depsExtraArgs"
    "cargoUpdateHook"
    "cargoDeps"
    "cargoLock"
  ])
  // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && buildType == "debug") {
  lib.optionalAttrs (stdenv.hostPlatform.isDarwin && buildType == "debug") {
    RUSTFLAGS = "-C split-debuginfo=packed " + (args.RUSTFLAGS or "");
  }
  // {
@@ -194,5 +198,5 @@ stdenv.mkDerivation (
      # default to Rust's platforms
      platforms = lib.intersectLists meta.platforms or lib.platforms.all rustc.targetPlatforms;
    };
  };
}
)