lol
1{ stdenv, fetchurl, perl, groff
2, ghostscript #for postscript and html output
3, psutils, netpbm #for html output
4, buildPackages
5}:
6
7stdenv.mkDerivation rec {
8 name = "groff-1.22.3";
9
10 src = fetchurl {
11 url = "mirror://gnu/groff/${name}.tar.gz";
12 sha256 = "1998v2kcs288d3y7kfxpvl369nqi06zbbvjzafyvyl3pr7bajj1s";
13 };
14
15 outputs = [ "out" "man" "doc" "info" ];
16
17 enableParallelBuilding = false;
18
19 postPatch = stdenv.lib.optionalString (psutils != null) ''
20 substituteInPlace src/preproc/html/pre-html.cpp \
21 --replace "psselect" "${psutils}/bin/psselect"
22 '' + stdenv.lib.optionalString (netpbm != null) ''
23 substituteInPlace src/preproc/html/pre-html.cpp \
24 --replace "pnmcut" "${netpbm}/bin/pnmcut" \
25 --replace "pnmcrop" "${netpbm}/bin/pnmcrop" \
26 --replace "pnmtopng" "${netpbm}/bin/pnmtopng"
27 substituteInPlace tmac/www.tmac \
28 --replace "pnmcrop" "${netpbm}/bin/pnmcrop" \
29 --replace "pngtopnm" "${netpbm}/bin/pngtopnm" \
30 --replace "@PNMTOPS_NOSETPAGE@" "${netpbm}/bin/pnmtops -nosetpage"
31 '';
32
33 buildInputs = [ ghostscript psutils netpbm ];
34 nativeBuildInputs = [ perl ];
35
36 # Builds running without a chroot environment may detect the presence
37 # of /usr/X11 in the host system, leading to an impure build of the
38 # package. To avoid this issue, X11 support is explicitly disabled.
39 # Note: If we ever want to *enable* X11 support, then we'll probably
40 # have to pass "--with-appresdir", too.
41 configureFlags = [
42 "--without-x"
43 ] ++ stdenv.lib.optionals (ghostscript != null) [
44 "--with-gs=${ghostscript}/bin/gs"
45 ];
46
47 doCheck = true;
48
49 crossAttrs = {
50 # Trick to get the build system find the proper 'native' groff
51 # http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html
52 preBuild = ''
53 makeFlags="GROFF_BIN_PATH=${buildPackages.groff}/bin GROFFBIN=${buildPackages.groff}/bin/groff"
54 '';
55 };
56
57 # Remove example output with (random?) colors and creation date
58 # to avoid non-determinism in the output.
59 postInstall = ''
60 rm "$doc"/share/doc/groff/examples/hdtbl/*color*ps
61 find "$doc"/share/doc/groff/ -type f -print0 | xargs -0 sed -i -e 's/%%CreationDate: .*//'
62 for f in 'man.local' 'mdoc.local'; do
63 cat '${./site.tmac}' >>"$out/share/groff/site-tmac/$f"
64 done
65 '';
66
67 meta = with stdenv.lib; {
68 homepage = http://www.gnu.org/software/groff/;
69 description = "GNU Troff, a typesetting package that reads plain text and produces formatted output";
70 license = licenses.gpl3Plus;
71 platforms = platforms.all;
72 maintainers = with maintainers; [ pSub ];
73
74 longDescription = ''
75 groff is the GNU implementation of troff, a document formatting
76 system. Included in this release are implementations of troff,
77 pic, eqn, tbl, grn, refer, -man, -mdoc, -mom, and -ms macros,
78 and drivers for PostScript, TeX dvi format, HP LaserJet 4
79 printers, Canon CAPSL printers, HTML and XHTML format (beta
80 status), and typewriter-like devices. Also included is a
81 modified version of the Berkeley -me macros, the enhanced
82 version gxditview of the X11 xditview previewer, and an
83 implementation of the -mm macros.
84 '';
85 };
86}