buildRustCrate: support rust editions

In combination with carnix we can now build crates that require a
specific edition of rust features. A few crates started requiring that
already and having this in nixpkgs is just logical.
This commit is contained in:
Andreas Rammhold 2019-02-18 01:09:54 +01:00
parent 044a8a24ed
commit 6a3b144d02
No known key found for this signature in database
GPG Key ID: E432E410B5E48C86

View File

@ -71,7 +71,7 @@ let crate = crate_ // (lib.attrByPath [ crate_.crateName ] (attr: {}) crateOverr
processedAttrs = [
"src" "buildInputs" "crateBin" "crateLib" "libName" "libPath"
"buildDependencies" "dependencies" "features"
"crateName" "version" "build" "authors" "colors"
"crateName" "version" "build" "authors" "colors" "edition"
];
extraDerivationAttrs = lib.filterAttrs (n: v: ! lib.elem n processedAttrs) crate;
buildInputs_ = buildInputs;
@ -136,7 +136,9 @@ stdenv.mkDerivation (rec {
(crate.type or ["lib"]);
colors = lib.attrByPath [ "colors" ] "always" crate;
extraLinkFlags = builtins.concatStringsSep " " (crate.extraLinkFlags or []);
extraRustcOpts = (if crate ? extraRustcOpts then crate.extraRustcOpts else []) ++ extraRustcOpts_;
edition = crate.edition or null;
extraRustcOpts = (if crate ? extraRustcOpts then crate.extraRustcOpts else []) ++ extraRustcOpts_ ++ (lib.optional (edition != null) "--edition ${edition}");
configurePhase = configureCrate {
inherit crateName buildDependencies completeDeps completeBuildDeps
crateFeatures libName build workspace_member release libPath crateVersion