buildRustCrate: slight "rewording" and reformatting

There is no point in reinventinb builtins through `filterAttrs` or the
like. Lets just stick to what we already have in our toolbelt.
This commit is contained in:
Andreas Rammhold 2019-12-18 00:51:26 +01:00
parent a3a51763f9
commit 3e61906e1c
No known key found for this signature in database
GPG Key ID: E432E410B5E48C86
1 changed files with 18 additions and 8 deletions

View File

@ -55,8 +55,9 @@ let crate = crate_ // (lib.attrByPath [ crate_.crateName ] (attr: {}) crateOverr
"src" "buildInputs" "crateBin" "crateLib" "libName" "libPath" "src" "buildInputs" "crateBin" "crateLib" "libName" "libPath"
"buildDependencies" "dependencies" "features" "crateRenames" "buildDependencies" "dependencies" "features" "crateRenames"
"crateName" "version" "build" "authors" "colors" "edition" "crateName" "version" "build" "authors" "colors" "edition"
"buildTests"
]; ];
extraDerivationAttrs = lib.filterAttrs (n: v: ! lib.elem n processedAttrs) crate; extraDerivationAttrs = builtins.removeAttrs crate processedAttrs;
buildInputs_ = buildInputs; buildInputs_ = buildInputs;
extraRustcOpts_ = extraRustcOpts; extraRustcOpts_ = extraRustcOpts;
buildTests_ = buildTests; buildTests_ = buildTests;
@ -73,13 +74,23 @@ in
stdenv.mkDerivation (rec { stdenv.mkDerivation (rec {
inherit (crate) crateName; inherit (crate) crateName;
inherit preUnpack postUnpack prePatch patches postPatch preConfigure postConfigure preBuild postBuild preInstall postInstall; inherit
preUnpack
postUnpack
prePatch
patches
postPatch
preConfigure
postConfigure
preBuild
postBuild
preInstall
postInstall
buildTests
;
src = if lib.hasAttr "src" crate then src = crate.src or (fetchCrate { inherit (crate) crateName version sha256; });
crate.src name = "rust_${crate.crateName}-${crate.version}${lib.optionalString buildTests_ "-test"}";
else
fetchCrate { inherit (crate) crateName version sha256; };
name = "rust_${crate.crateName}-${crate.version}${lib.optionalString buildTests "-test"}";
depsBuildBuild = [ rust stdenv.cc ]; depsBuildBuild = [ rust stdenv.cc ];
buildInputs = (crate.buildInputs or []) ++ buildInputs_; buildInputs = (crate.buildInputs or []) ++ buildInputs_;
dependencies = makeDependencies dependencies_; dependencies = makeDependencies dependencies_;
@ -123,7 +134,6 @@ stdenv.mkDerivation (rec {
++ extraRustcOpts_ ++ extraRustcOpts_
++ (lib.optional (edition != null) "--edition ${edition}"); ++ (lib.optional (edition != null) "--edition ${edition}");
buildTests = buildTests_;
configurePhase = configureCrate { configurePhase = configureCrate {
inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription inherit crateName buildDependencies completeDeps completeBuildDeps crateDescription