mercurial: add withExtensions
This allows an easy way of getting a copy of the "hg" executable which provides a specific set of extensions.
This commit is contained in:
parent
dcf3dec494
commit
cdcb439bad
@ -1,4 +1,4 @@
|
||||
{ lib, stdenv, fetchurl, fetchpatch, python3Packages, makeWrapper, gettext
|
||||
{ lib, stdenv, fetchurl, fetchpatch, python3Packages, makeWrapper, gettext, installShellFiles
|
||||
, re2Support ? true
|
||||
, rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform
|
||||
, fullBuild ? false
|
||||
@ -11,7 +11,7 @@
|
||||
let
|
||||
inherit (python3Packages) docutils python fb-re2 pygit2 pygments;
|
||||
|
||||
in python3Packages.buildPythonApplication rec {
|
||||
self = python3Packages.buildPythonApplication rec {
|
||||
pname = "mercurial";
|
||||
version = "5.8";
|
||||
|
||||
@ -48,7 +48,7 @@ in python3Packages.buildPythonApplication rec {
|
||||
propagatedBuildInputs = lib.optional re2Support fb-re2
|
||||
++ lib.optional gitSupport pygit2
|
||||
++ lib.optional highlightSupport pygments;
|
||||
nativeBuildInputs = [ makeWrapper gettext ]
|
||||
nativeBuildInputs = [ makeWrapper gettext installShellFiles ]
|
||||
++ lib.optionals rustSupport (with rustPlatform; [
|
||||
cargoSetupHook
|
||||
rust.cargo
|
||||
@ -82,11 +82,13 @@ in python3Packages.buildPythonApplication rec {
|
||||
cp -v hgweb.cgi contrib/hgweb.wsgi $out/share/cgi-bin
|
||||
chmod u+x $out/share/cgi-bin/hgweb.cgi
|
||||
|
||||
# install bash/zsh completions
|
||||
install -v -m644 -D contrib/bash_completion $out/share/bash-completion/completions/_hg
|
||||
install -v -m644 -D contrib/zsh_completion $out/share/zsh/site-functions/_hg
|
||||
installShellCompletion --cmd hg \
|
||||
--bash contrib/bash_completion \
|
||||
--zsh contrib/zsh_completion
|
||||
'';
|
||||
|
||||
passthru.tests = {};
|
||||
|
||||
meta = with lib; {
|
||||
inherit version;
|
||||
description = "A fast, lightweight SCM system for very large distributed projects";
|
||||
@ -97,4 +99,60 @@ in python3Packages.buildPythonApplication rec {
|
||||
updateWalker = true;
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
}
|
||||
};
|
||||
in
|
||||
self.overridePythonAttrs (origAttrs: {
|
||||
passthru = origAttrs.passthru // rec {
|
||||
# withExtensions takes a function which takes the python packages set and
|
||||
# returns a list of extensions to install.
|
||||
#
|
||||
# for instance: mercurial.withExtension (pm: [ pm.hg-evolve ])
|
||||
withExtensions = f: let
|
||||
python = self.python;
|
||||
mercurialHighPrio = ps: (ps.toPythonModule self).overrideAttrs (oldAttrs: {
|
||||
meta = oldAttrs.meta // {
|
||||
priority = 50;
|
||||
};
|
||||
});
|
||||
plugins = (f python.pkgs) ++ [ (mercurialHighPrio python.pkgs) ];
|
||||
env = python.withPackages (ps: plugins);
|
||||
in stdenv.mkDerivation {
|
||||
pname = "${self.pname}-with-extensions";
|
||||
|
||||
inherit (self) src version meta;
|
||||
|
||||
buildInputs = self.buildInputs ++ self.propagatedBuildInputs;
|
||||
nativeBuildInputs = self.nativeBuildInputs;
|
||||
|
||||
phases = [ "installPhase" "installCheckPhase" ];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
mkdir -p $out/bin
|
||||
|
||||
for bindir in ${lib.concatStringsSep " " (map (d: "${lib.getBin d}/bin") plugins)}; do
|
||||
for bin in $bindir/*; do
|
||||
ln -s ${env}/bin/$(basename $bin) $out/bin/
|
||||
done
|
||||
done
|
||||
|
||||
ln -s ${self}/share $out/share
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
installCheckPhase = ''
|
||||
runHook preInstallCheck
|
||||
|
||||
$out/bin/hg help >/dev/null || exit 1
|
||||
|
||||
runHook postInstallCheck
|
||||
'';
|
||||
};
|
||||
|
||||
tests = origAttrs.passthru.tests // {
|
||||
withExtensions = withExtensions (pm: [ pm.hg-evolve ]);
|
||||
};
|
||||
};
|
||||
})
|
||||
|
Loading…
Reference in New Issue
Block a user