diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix index df58b2162fc1..3394d44a4be1 100644 --- a/pkgs/applications/version-management/mercurial/default.nix +++ b/pkgs/applications/version-management/mercurial/default.nix @@ -1,95 +1,158 @@ -{ lib, stdenv, fetchurl, fetchpatch, python3Packages, makeWrapper, gettext +{ lib, stdenv, fetchurl, fetchpatch, python3Packages, makeWrapper, gettext, installShellFiles , re2Support ? true , rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform -, guiSupport ? false, tk ? null +, fullBuild ? false +, gitSupport ? fullBuild +, guiSupport ? fullBuild, tk +, highlightSupport ? fullBuild , ApplicationServices }: let - inherit (python3Packages) docutils python fb-re2; + inherit (python3Packages) docutils python fb-re2 pygit2 pygments; -in python3Packages.buildPythonApplication rec { - pname = "mercurial"; - version = "5.8"; + self = python3Packages.buildPythonApplication rec { + pname = "mercurial"; + version = "5.8"; - src = fetchurl { - url = "https://mercurial-scm.org/release/mercurial-${version}.tar.gz"; - sha256 = "17rhlmmkqz5ll3k68jfzpcifg3nndbcbc2nx7kw8xn3qcj7nlpgw"; + src = fetchurl { + url = "https://mercurial-scm.org/release/mercurial-${version}.tar.gz"; + sha256 = "17rhlmmkqz5ll3k68jfzpcifg3nndbcbc2nx7kw8xn3qcj7nlpgw"; + }; + + patches = [ + # https://phab.mercurial-scm.org/D10638, needed for below patch to apply + (fetchpatch { + url = "https://www.mercurial-scm.org/repo/hg/raw-rev/c365850b611490a5fdb235eb1cea310a542c2f84"; + sha256 = "1gn3xvahbjdhbglffqpmj559w1bkqqsk70wqcanwv7nh972aqy9g"; + }) + # https://phab.mercurial-scm.org/D10639, fixes https://bz.mercurial-scm.org/show_bug.cgi?id=6514 + (fetchpatch { + url = "https://www.mercurial-scm.org/repo/hg/raw-rev/c8f62920f07a40af3403ba9aefa1dac8a97d53ea"; + sha256 = "1kw0xjg2c4jby0ncarjvpa5qafsyl1wzbk6jxls4hnxlxdl53nmn"; + }) + ]; + + format = "other"; + + passthru = { inherit python; }; # pass it so that the same version can be used in hg2git + + 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; + + propagatedBuildInputs = lib.optional re2Support fb-re2 + ++ lib.optional gitSupport pygit2 + ++ lib.optional highlightSupport pygments; + nativeBuildInputs = [ makeWrapper gettext installShellFiles ] + ++ lib.optionals rustSupport (with rustPlatform; [ + cargoSetupHook + rust.cargo + rust.rustc + ]); + buildInputs = [ docutils ] + ++ lib.optionals stdenv.isDarwin [ ApplicationServices ]; + + makeFlags = [ "PREFIX=$(out)" ] + ++ lib.optional rustSupport "PURE=--rust"; + + postInstall = (lib.optionalString guiSupport '' + mkdir -p $out/etc/mercurial + cp contrib/hgk $out/bin + cat >> $out/etc/mercurial/hgrc << EOF + [extensions] + hgk=$out/lib/${python.libPrefix}/site-packages/hgext/hgk.py + EOF + # setting HG so that hgk can be run itself as well (not only hg view) + WRAP_TK=" --set TK_LIBRARY ${tk}/lib/${tk.libPrefix} + --set HG $out/bin/hg + --prefix PATH : ${tk}/bin " + '') + '' + for i in $(cd $out/bin && ls); do + wrapProgram $out/bin/$i \ + $WRAP_TK + done + + # copy hgweb.cgi to allow use in apache + mkdir -p $out/share/cgi-bin + cp -v hgweb.cgi contrib/hgweb.wsgi $out/share/cgi-bin + chmod u+x $out/share/cgi-bin/hgweb.cgi + + 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"; + homepage = "https://www.mercurial-scm.org"; + downloadPage = "https://www.mercurial-scm.org/release/"; + license = licenses.gpl2Plus; + maintainers = with maintainers; [ eelco lukegb ]; + 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"; - patches = [ - # https://phab.mercurial-scm.org/D10638, needed for below patch to apply - (fetchpatch { - url = "https://phab.mercurial-scm.org/file/data/l7p2r4zcctcr3pzlybv2/PHID-FILE-bwjzxlz6sbegk3s4irik/D10638.diff"; - sha256 = "0mfi324is02l7cnd3j0gbmg5rpyyqn3afg3f73flnfwmz5njqa5f"; - }) - # https://phab.mercurial-scm.org/D10639, fixes https://bz.mercurial-scm.org/show_bug.cgi?id=6514 - (fetchpatch { - url = "https://phab.mercurial-scm.org/file/data/v53nhburhtkhpccyecei/PHID-FILE-6v34oll6r2gkqo4ng5nt/D10639.diff"; - sha256 = "0h5ilrd2x1789fr6sf4k1mcvxdh0xdyr94yawdacw87v3x12c8cb"; - }) - ]; + inherit (self) src version meta; - format = "other"; + buildInputs = self.buildInputs ++ self.propagatedBuildInputs; + nativeBuildInputs = self.nativeBuildInputs; - passthru = { inherit python; }; # pass it so that the same version can be used in hg2git + phases = [ "installPhase" "installCheckPhase" ]; - 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; + installPhase = '' + runHook preInstall - propagatedBuildInputs = lib.optional re2Support fb-re2; - nativeBuildInputs = [ makeWrapper gettext ] - ++ lib.optionals rustSupport (with rustPlatform; [ - cargoSetupHook - rust.cargo - rust.rustc - ]); - buildInputs = [ docutils ] - ++ lib.optionals stdenv.isDarwin [ ApplicationServices ]; + mkdir -p $out/bin - makeFlags = [ "PREFIX=$(out)" ] - ++ lib.optional rustSupport "PURE=--rust"; + 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 - postInstall = (lib.optionalString guiSupport '' - mkdir -p $out/etc/mercurial - cp contrib/hgk $out/bin - cat >> $out/etc/mercurial/hgrc << EOF - [extensions] - hgk=$out/lib/${python.libPrefix}/site-packages/hgext/hgk.py - EOF - # setting HG so that hgk can be run itself as well (not only hg view) - WRAP_TK=" --set TK_LIBRARY ${tk}/lib/${tk.libPrefix} - --set HG $out/bin/hg - --prefix PATH : ${tk}/bin " - '') + '' - for i in $(cd $out/bin && ls); do - wrapProgram $out/bin/$i \ - $WRAP_TK - done + ln -s ${self}/share $out/share - # copy hgweb.cgi to allow use in apache - mkdir -p $out/share/cgi-bin - cp -v hgweb.cgi contrib/hgweb.wsgi $out/share/cgi-bin - chmod u+x $out/share/cgi-bin/hgweb.cgi + runHook postInstall + ''; - # 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 - ''; + installCheckPhase = '' + runHook preInstallCheck - meta = with lib; { - inherit version; - description = "A fast, lightweight SCM system for very large distributed projects"; - homepage = "https://www.mercurial-scm.org"; - downloadPage = "https://www.mercurial-scm.org/release/"; - license = licenses.gpl2Plus; - maintainers = with maintainers; [ eelco lukegb ]; - updateWalker = true; - platforms = platforms.unix; - }; -} + $out/bin/hg help >/dev/null || exit 1 + + runHook postInstallCheck + ''; + }; + + tests = origAttrs.passthru.tests // { + withExtensions = withExtensions (pm: [ pm.hg-evolve ]); + }; + }; + }) diff --git a/pkgs/applications/version-management/tortoisehg/default.nix b/pkgs/applications/version-management/tortoisehg/default.nix index a0fa9318a13f..17cde4c8a540 100644 --- a/pkgs/applications/version-management/tortoisehg/default.nix +++ b/pkgs/applications/version-management/tortoisehg/default.nix @@ -1,25 +1,16 @@ { lib, fetchurl, python3Packages , mercurial, qt5 -}@args: +}: let tortoisehgSrc = fetchurl rec { meta.name = "tortoisehg-${meta.version}"; - meta.version = "5.6"; + meta.version = "5.8"; url = "https://www.mercurial-scm.org/release/tortoisehg/targz/tortoisehg-${meta.version}.tar.gz"; - sha256 = "031bafj88wggpvw0lgvl0djhlbhs9nls9vzwvni8yn0m0bgzc9gr"; + sha256 = "154q7kyrdk045wx7rsblzx41k3wbvp2f40kzkxmiiaa5n35srsm3"; }; - tortoiseMercurial = (mercurial.override { - rustSupport = false; - re2Support = lib.versionAtLeast tortoisehgSrc.meta.version "5.8"; - }).overridePythonAttrs (old: rec { - inherit (tortoisehgSrc.meta) version; - src = fetchurl { - url = "https://mercurial-scm.org/release/mercurial-${version}.tar.gz"; - sha256 = "1hk2y30zzdnlv8f71kabvh0xi9c7qhp28ksh20vpd0r712sv79yz"; - }; - patches = []; - }); + # Extension point for when thg's mercurial is lagging behind mainline. + tortoiseMercurial = mercurial; in python3Packages.buildPythonApplication { inherit (tortoisehgSrc.meta) name version; @@ -49,7 +40,7 @@ in python3Packages.buildPythonApplication { meta = { description = "Qt based graphical tool for working with Mercurial"; homepage = "https://tortoisehg.bitbucket.io/"; - license = lib.licenses.gpl2; + license = lib.licenses.gpl2Only; platforms = lib.platforms.linux; maintainers = with lib.maintainers; [ danbst ]; }; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1415e4fc4f6b..7de996cb636a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25416,7 +25416,7 @@ in inherit (darwin.apple_sdk.frameworks) ApplicationServices; }; - mercurialFull = appendToName "full" (pkgs.mercurial.override { guiSupport = true; }); + mercurialFull = appendToName "full" (pkgs.mercurial.override { fullBuild = true; }); merkaartor = libsForQt5.callPackage ../applications/misc/merkaartor { };