1{
2 stdenv,
3 lib,
4 rustPlatform,
5 fetchFromGitHub,
6 pkg-config,
7 installShellFiles,
8 makeWrapper,
9 asciidoc,
10 docbook_xsl,
11 docbook_xml_dtd_45,
12 xmlto,
13 curl,
14 git,
15 perl,
16 darwin,
17 libiconv,
18}:
19
20rustPlatform.buildRustPackage rec {
21 pname = "stgit";
22 version = "2.5.3";
23
24 src = fetchFromGitHub {
25 owner = "stacked-git";
26 repo = "stgit";
27 rev = "v${version}";
28 hash = "sha256-YrJf4uNICPmXpuJvf0QRDHpODw39Q+40SLZuoIwZ5qA=";
29 };
30
31 cargoHash = "sha256-Y3969dpfbKJR22yjw5MHsG3+EJyui0bQFQ585wLzXUk=";
32
33 nativeBuildInputs = [
34 pkg-config
35 installShellFiles
36 makeWrapper
37 asciidoc
38 xmlto
39 docbook_xsl
40 docbook_xml_dtd_45
41 perl
42 ];
43 buildInputs = [ curl ];
44
45 nativeCheckInputs = [
46 git
47 perl
48 ]
49 ++ lib.optionals stdenv.hostPlatform.isDarwin [
50 darwin.system_cmds
51 libiconv
52 ];
53
54 postPatch = ''
55 for f in Documentation/*.xsl; do
56 substituteInPlace $f \
57 --replace http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl \
58 ${docbook_xsl}/xml/xsl/docbook/manpages/docbook.xsl \
59 --replace http://docbook.sourceforge.net/release/xsl/current/html/docbook.xsl \
60 ${docbook_xsl}/xml/xsl/docbook/html/docbook.xsl
61 done
62
63 substituteInPlace Documentation/texi.xsl \
64 --replace http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd \
65 ${docbook_xml_dtd_45}/xml/dtd/docbook/docbookx.dtd
66 '';
67
68 makeFlags = [
69 "prefix=${placeholder "out"}"
70 "XMLTO_EXTRA=--skip-validation"
71 "PERL_PATH=${perl}/bin/perl"
72 ];
73
74 dontCargoBuild = true;
75 buildFlags = [ "all" ];
76
77 dontCargoCheck = true;
78 checkTarget = "test";
79
80 dontCargoInstall = true;
81 installTargets = [
82 "install"
83 "install-man"
84 "install-html"
85 ];
86
87 postInstall = ''
88 wrapProgram $out/bin/stg --prefix PATH : ${lib.makeBinPath [ git ]}
89
90 installShellCompletion --cmd stg \
91 --fish completion/stg.fish \
92 --bash completion/stgit.bash \
93 --zsh completion/stgit.zsh
94 '';
95
96 meta = with lib; {
97 description = "Patch manager implemented on top of Git";
98 homepage = "https://stacked-git.github.io/";
99 license = licenses.gpl2Only;
100 platforms = platforms.unix;
101 maintainers = with maintainers; [ jshholland ];
102 mainProgram = "stg";
103 };
104}