1{ lib
2, fetchFromGitHub
3, installShellFiles
4, python3Packages
5, asciidoc
6, docbook_xsl
7, docbook_xml_dtd_45
8, git
9, perl
10, xmlto
11}:
12
13python3Packages.buildPythonApplication rec {
14 pname = "stgit";
15 version = "1.4";
16
17 src = fetchFromGitHub {
18 owner = "stacked-git";
19 repo = "stgit";
20 rev = "v${version}";
21 sha256 = "0yx81d61kp33h7n0c14wvcrh8vvjjjq4xjh1qwq2sdbmqc43p3hg";
22 };
23
24 nativeBuildInputs = [ installShellFiles asciidoc xmlto docbook_xsl docbook_xml_dtd_45 ];
25
26 format = "other";
27
28 checkInputs = [ git perl ];
29
30 postPatch = ''
31 for f in Documentation/*.xsl; do
32 substituteInPlace $f \
33 --replace http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl \
34 ${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl \
35 --replace http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl \
36 ${docbook_xsl}/xml/xsl/docbook/html/docbook.xsl
37 done
38
39 substituteInPlace Documentation/texi.xsl \
40 --replace http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd \
41 ${docbook_xml_dtd_45}/xml/dtd/docbook/docbookx.dtd
42
43 cat > stgit/_version.py <<EOF
44 __version__ = "${version}"
45 EOF
46 '';
47
48 makeFlags = [
49 "prefix=${placeholder "out"}"
50 "MAN_BASE_URL=${placeholder "out"}/share/man"
51 "XMLTO_EXTRA=--skip-validation"
52 ];
53
54 buildFlags = [ "all" "doc" ];
55
56 checkTarget = "test";
57 checkFlags = [ "PERL_PATH=${perl}/bin/perl" ];
58
59 installTargets = [ "install" "install-doc" "install-html" ];
60 postInstall = ''
61 installShellCompletion --cmd stg \
62 --fish completion/stg.fish \
63 --bash completion/stgit.bash \
64 --zsh completion/stgit.zsh
65 '';
66
67 meta = with lib; {
68 description = "A patch manager implemented on top of Git";
69 homepage = "https://stacked-git.github.io/";
70 license = licenses.gpl2Only;
71 platforms = platforms.unix;
72 maintainers = with maintainers; [ jshholland ];
73 };
74}