From c83a5bce66b68e4ce4d9dfce3a9a45265418e15b Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sun, 6 Jun 2021 15:19:15 +0000 Subject: [PATCH 1/5] mercurialFull: add support for experimental in-tree git extension The git extension is bundled in-tree, similarly to the hg gui, but also requires pygit2. Enable it for mercurialFull, but don't bother with it for the stock mercurial install. Alas, it doesn't (yet?) work on nixpkgs because it doesn't support octopus merges: mercurial.error.ProgrammingError: git support can't handle octopus merges, found a commit with 16 parents :( I'm sure that commit is loved equally by all 16 parents. --- pkgs/applications/version-management/mercurial/default.nix | 7 ++++--- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix index df58b2162fc1..b5609b584866 100644 --- a/pkgs/applications/version-management/mercurial/default.nix +++ b/pkgs/applications/version-management/mercurial/default.nix @@ -1,12 +1,13 @@ { lib, stdenv, fetchurl, fetchpatch, python3Packages, makeWrapper, gettext , re2Support ? true , rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform -, guiSupport ? false, tk ? null +, gitSupport ? false +, guiSupport ? false, tk , ApplicationServices }: let - inherit (python3Packages) docutils python fb-re2; + inherit (python3Packages) docutils python fb-re2 pygit2; in python3Packages.buildPythonApplication rec { pname = "mercurial"; @@ -42,7 +43,7 @@ in python3Packages.buildPythonApplication rec { } else null; cargoRoot = if rustSupport then "rust" else null; - propagatedBuildInputs = lib.optional re2Support fb-re2; + propagatedBuildInputs = lib.optional re2Support fb-re2 ++ lib.optional gitSupport pygit2; nativeBuildInputs = [ makeWrapper gettext ] ++ lib.optionals rustSupport (with rustPlatform; [ cargoSetupHook diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index bb12c3c8df11..d6ec5a409cb3 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25423,7 +25423,7 @@ in inherit (darwin.apple_sdk.frameworks) ApplicationServices; }; - mercurialFull = appendToName "full" (pkgs.mercurial.override { guiSupport = true; }); + mercurialFull = appendToName "full" (pkgs.mercurial.override { guiSupport = true; gitSupport = true; }); merkaartor = libsForQt5.callPackage ../applications/misc/merkaartor { }; From 67444f8a393846b1431cfeb936e83a9f24725e2d Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 3 Jul 2021 10:41:13 +0000 Subject: [PATCH 2/5] mercurial: fix patch links again The conclusion is that Phabricator does not, in fact, generate stable patch links. In any case, these have landed, so we can just use the patches from Mercurial's hgweb instance instead, which should be more stable. --- .../applications/version-management/mercurial/default.nix | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix index b5609b584866..cddb3ade4e36 100644 --- a/pkgs/applications/version-management/mercurial/default.nix +++ b/pkgs/applications/version-management/mercurial/default.nix @@ -21,13 +21,13 @@ in python3Packages.buildPythonApplication rec { 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"; + 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://phab.mercurial-scm.org/file/data/v53nhburhtkhpccyecei/PHID-FILE-6v34oll6r2gkqo4ng5nt/D10639.diff"; - sha256 = "0h5ilrd2x1789fr6sf4k1mcvxdh0xdyr94yawdacw87v3x12c8cb"; + url = "https://www.mercurial-scm.org/repo/hg/raw-rev/c8f62920f07a40af3403ba9aefa1dac8a97d53ea"; + sha256 = "1kw0xjg2c4jby0ncarjvpa5qafsyl1wzbk6jxls4hnxlxdl53nmn"; }) ]; From dcf3dec494f34eb4b9f04b78d2eb40686b08d6a4 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 3 Jul 2021 10:56:29 +0000 Subject: [PATCH 3/5] mercurialFull: add highlight in-tree extension support This also moves the individual flag flips from the mercurialFull definition in all-packages into the mercurial module itself. --- .../version-management/mercurial/default.nix | 12 ++++++++---- pkgs/top-level/all-packages.nix | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix index cddb3ade4e36..aba8cb6737dc 100644 --- a/pkgs/applications/version-management/mercurial/default.nix +++ b/pkgs/applications/version-management/mercurial/default.nix @@ -1,13 +1,15 @@ { lib, stdenv, fetchurl, fetchpatch, python3Packages, makeWrapper, gettext , re2Support ? true , rustSupport ? stdenv.hostPlatform.isLinux, rustPlatform -, gitSupport ? false -, guiSupport ? false, tk +, fullBuild ? false +, gitSupport ? fullBuild +, guiSupport ? fullBuild, tk +, highlightSupport ? fullBuild , ApplicationServices }: let - inherit (python3Packages) docutils python fb-re2 pygit2; + inherit (python3Packages) docutils python fb-re2 pygit2 pygments; in python3Packages.buildPythonApplication rec { pname = "mercurial"; @@ -43,7 +45,9 @@ in python3Packages.buildPythonApplication rec { } else null; cargoRoot = if rustSupport then "rust" else null; - propagatedBuildInputs = lib.optional re2Support fb-re2 ++ lib.optional gitSupport pygit2; + propagatedBuildInputs = lib.optional re2Support fb-re2 + ++ lib.optional gitSupport pygit2 + ++ lib.optional highlightSupport pygments; nativeBuildInputs = [ makeWrapper gettext ] ++ lib.optionals rustSupport (with rustPlatform; [ cargoSetupHook diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d6ec5a409cb3..676d7240ee95 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -25423,7 +25423,7 @@ in inherit (darwin.apple_sdk.frameworks) ApplicationServices; }; - mercurialFull = appendToName "full" (pkgs.mercurial.override { guiSupport = true; gitSupport = true; }); + mercurialFull = appendToName "full" (pkgs.mercurial.override { fullBuild = true; }); merkaartor = libsForQt5.callPackage ../applications/misc/merkaartor { }; From cdcb439bad262467206e2957a4994e440d4af765 Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 3 Jul 2021 11:32:01 +0000 Subject: [PATCH 4/5] mercurial: add withExtensions This allows an easy way of getting a copy of the "hg" executable which provides a specific set of extensions. --- .../version-management/mercurial/default.nix | 210 +++++++++++------- 1 file changed, 134 insertions(+), 76 deletions(-) diff --git a/pkgs/applications/version-management/mercurial/default.nix b/pkgs/applications/version-management/mercurial/default.nix index aba8cb6737dc..3394d44a4be1 100644 --- a/pkgs/applications/version-management/mercurial/default.nix +++ b/pkgs/applications/version-management/mercurial/default.nix @@ -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,90 +11,148 @@ let 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://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"; - }) - ]; + 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 - ++ lib.optional gitSupport pygit2 - ++ lib.optional highlightSupport pygments; - 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 ]); + }; + }; + }) From 65a67517c9cea9768a05e0aacab8530ef4121b5e Mon Sep 17 00:00:00 2001 From: Luke Granger-Brown Date: Sat, 3 Jul 2021 18:12:34 +0000 Subject: [PATCH 5/5] tortoisehg: 5.6 -> 5.8 --- .../version-management/tortoisehg/default.nix | 21 ++++++------------- 1 file changed, 6 insertions(+), 15 deletions(-) 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 ]; };