mercurial: build Rust extensions

The Rust extensions provide speedups for core Mercurial functionality.
We should start building with them.

They're only CI-tested on Linux, so they're disabled for non-Linux
platforms for now by default.
This commit is contained in:
Luke Granger-Brown 2021-05-03 18:05:01 +00:00
parent ae894f63f5
commit 0716841463
1 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,5 @@
{ lib, stdenv, fetchurl, python3Packages, makeWrapper
, rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform
, guiSupport ? false, tk ? null
, ApplicationServices
}:
@ -19,11 +20,25 @@ in python3Packages.buildPythonApplication rec {
passthru = { inherit python; }; # pass it so that the same version can be used in hg2git
nativeBuildInputs = [ makeWrapper ];
cargoDeps = if rustSupport then rustPlatform.fetchCargoTarball {
inherit src;
name = "${pname}-${version}";
sha256 = "1kc2giqvfwsdl5fb0qmz96ws1gdrs3skfdzvpiif2i8f7r4nqlhd";
sourceRoot = "${pname}-${version}/rust";
} else null;
cargoRoot = if rustSupport then "rust" else null;
nativeBuildInputs = [ makeWrapper ]
++ lib.optionals rustSupport (with rustPlatform; [
cargoSetupHook
rust.cargo
rust.rustc
]);
buildInputs = [ docutils ]
++ lib.optionals stdenv.isDarwin [ ApplicationServices ];
makeFlags = [ "PREFIX=$(out)" ];
makeFlags = [ "PREFIX=$(out)" ]
++ lib.optional rustSupport "PURE=--rust";
postInstall = (lib.optionalString guiSupport ''
mkdir -p $out/etc/mercurial