From 0716841463629a08ac69fca4a8645b3eede030a6 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Mon, 3 May 2021 18:05:01 +0000 Subject: [PATCH] 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. --- .../version-management/mercurial/default.nix | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix index 5d1611abd260..9ea983fc71be 100644 --- a/pkgs/applications/version-management/mercurial/default.nix +++ b/pkgs/applications/version-management/mercurial/default.nix @@ -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