buildRustPackage: restructure with lib.extendMkDerivation

Support fixed-point arguments with lib.extendMkDerivation

Postpone formatting for more concise diff.
This commit is contained in:
Yueh-Shun Li
2025-02-21 00:42:27 +08:00
parent 016ba92a43
commit 7609cbad7c
@@ -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;
};
}
)
};
}