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