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
|
, re2Support ? true
|
||||||
, rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform
|
, rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform
|
||||||
, fullBuild ? false
|
, fullBuild ? false
|
||||||
@ -11,7 +11,7 @@
|
|||||||
let
|
let
|
||||||
inherit (python3Packages) docutils python fb-re2 pygit2 pygments;
|
inherit (python3Packages) docutils python fb-re2 pygit2 pygments;
|
||||||
|
|
||||||
in python3Packages.buildPythonApplication rec {
|
self = python3Packages.buildPythonApplication rec {
|
||||||
pname = "mercurial";
|
pname = "mercurial";
|
||||||
version = "5.8";
|
version = "5.8";
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ in python3Packages.buildPythonApplication rec {
|
|||||||
propagatedBuildInputs = lib.optional re2Support fb-re2
|
propagatedBuildInputs = lib.optional re2Support fb-re2
|
||||||
++ lib.optional gitSupport pygit2
|
++ lib.optional gitSupport pygit2
|
||||||
++ lib.optional highlightSupport pygments;
|
++ lib.optional highlightSupport pygments;
|
||||||
nativeBuildInputs = [ makeWrapper gettext ]
|
nativeBuildInputs = [ makeWrapper gettext installShellFiles ]
|
||||||
++ lib.optionals rustSupport (with rustPlatform; [
|
++ lib.optionals rustSupport (with rustPlatform; [
|
||||||
cargoSetupHook
|
cargoSetupHook
|
||||||
rust.cargo
|
rust.cargo
|
||||||
@ -82,11 +82,13 @@ in python3Packages.buildPythonApplication rec {
|
|||||||
cp -v hgweb.cgi contrib/hgweb.wsgi $out/share/cgi-bin
|
cp -v hgweb.cgi contrib/hgweb.wsgi $out/share/cgi-bin
|
||||||
chmod u+x $out/share/cgi-bin/hgweb.cgi
|
chmod u+x $out/share/cgi-bin/hgweb.cgi
|
||||||
|
|
||||||
# install bash/zsh completions
|
installShellCompletion --cmd hg \
|
||||||
install -v -m644 -D contrib/bash_completion $out/share/bash-completion/completions/_hg
|
--bash contrib/bash_completion \
|
||||||
install -v -m644 -D contrib/zsh_completion $out/share/zsh/site-functions/_hg
|
--zsh contrib/zsh_completion
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
passthru.tests = {};
|
||||||
|
|
||||||
meta = with lib; {
|
meta = with lib; {
|
||||||
inherit version;
|
inherit version;
|
||||||
description = "A fast, lightweight SCM system for very large distributed projects";
|
description = "A fast, lightweight SCM system for very large distributed projects";
|
||||||
@ -97,4 +99,60 @@ in python3Packages.buildPythonApplication rec {
|
|||||||
updateWalker = true;
|
updateWalker = true;
|
||||||
platforms = platforms.unix;
|
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