1{ lib, stdenv, fetchurl, openssl, zlib, asciidoc, libxml2, libxslt
2, docbook_xsl, pkg-config, luajit
3, coreutils, gnused, groff, docutils
4, gzip, bzip2, lzip, xz, zstd
5, python, wrapPython, pygments, markdown
6}:
7
8stdenv.mkDerivation rec {
9 pname = "cgit";
10 version = "1.2.3";
11
12 src = fetchurl {
13 url = "https://git.zx2c4.com/cgit/snapshot/${pname}-${version}.tar.xz";
14 sha256 = "193d990ym10qlslk0p8mjwp2j6rhqa7fq0y1iff65lvbyv914pss";
15 };
16
17 # cgit is tightly coupled with git and needs a git source tree to build.
18 # IMPORTANT: Remember to check which git version cgit needs on every version
19 # bump (look for "GIT_VER" in the top-level Makefile).
20 gitSrc = fetchurl {
21 url = "mirror://kernel/software/scm/git/git-2.25.1.tar.xz";
22 sha256 = "09lzwa183nblr6l8ib35g2xrjf9wm9yhk3szfvyzkwivdv69c9r2";
23 };
24
25 nativeBuildInputs = [ pkg-config asciidoc ] ++ [ python wrapPython ];
26 buildInputs = [
27 openssl zlib libxml2 libxslt docbook_xsl luajit
28 ];
29 pythonPath = [ pygments markdown ];
30
31 postPatch = ''
32 sed -e 's|"gzip"|"${gzip}/bin/gzip"|' \
33 -e 's|"bzip2"|"${bzip2.bin}/bin/bzip2"|' \
34 -e 's|"lzip"|"${lzip}/bin/lzip"|' \
35 -e 's|"xz"|"${xz.bin}/bin/xz"|' \
36 -e 's|"zstd"|"${zstd}/bin/zstd"|' \
37 -i ui-snapshot.c
38
39 substituteInPlace filters/html-converters/man2html \
40 --replace 'groff' '${groff}/bin/groff'
41
42 substituteInPlace filters/html-converters/rst2html \
43 --replace 'rst2html.py' '${docutils}/bin/rst2html.py'
44 '';
45
46 # Give cgit a git source tree and pass configuration parameters (as make
47 # variables).
48 preBuild = ''
49 mkdir -p git
50 tar --strip-components=1 -xf "$gitSrc" -C git
51 '';
52
53 makeFlags = [
54 "prefix=$(out)"
55 "CGIT_SCRIPT_PATH=$(out)/cgit/"
56 "CC=${stdenv.cc.targetPrefix}cc"
57 "AR=${stdenv.cc.targetPrefix}ar"
58 ];
59
60 # Install manpage.
61 postInstall = ''
62 # xmllint fails:
63 #make install-man
64
65 # bypassing xmllint works:
66 a2x --no-xmllint -f manpage cgitrc.5.txt
67 mkdir -p "$out/share/man/man5"
68 cp cgitrc.5 "$out/share/man/man5"
69
70 wrapPythonProgramsIn "$out/lib/cgit/filters" "$out $pythonPath"
71
72 for script in $out/lib/cgit/filters/*.sh $out/lib/cgit/filters/html-converters/txt2html; do
73 wrapProgram $script --prefix PATH : '${lib.makeBinPath [ coreutils gnused ]}'
74 done
75 '';
76
77 stripDebugList = [ "cgit" ];
78
79 meta = {
80 homepage = "https://git.zx2c4.com/cgit/about/";
81 repositories.git = "git://git.zx2c4.com/cgit";
82 description = "Web frontend for git repositories";
83 license = lib.licenses.gpl2;
84 platforms = lib.platforms.linux;
85 maintainers = with lib.maintainers; [ bjornfor ];
86 };
87}