nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 perl,
6 enableGhostscript ? false,
7 ghostscript,
8 gawk,
9 libX11,
10 libXaw,
11 libXt,
12 libXmu, # for postscript and html output
13 enableHtml ? false,
14 psutils,
15 netpbm, # for html output
16 enableIconv ? false,
17 iconv,
18 enableLibuchardet ? false,
19 libuchardet, # for detecting input file encoding in preconv(1)
20 buildPackages,
21 autoreconfHook,
22 pkg-config,
23 texinfo,
24 bison,
25 bashNonInteractive,
26}:
27
28stdenv.mkDerivation rec {
29 pname = "groff";
30 version = "1.23.0";
31
32 src = fetchurl {
33 url = "mirror://gnu/groff/${pname}-${version}.tar.gz";
34 hash = "sha256-a5dX9ZK3UYtJAutq9+VFcL3Mujeocf3bLTCuOGNRHBM=";
35 };
36
37 patches = [
38 # Backport e49b934 "Fix underspecified `getenv()` prototype." for non-glibc systems with C23
39 # This can be dropped in the next release, when the local getopt implementation in libgroff is removed
40 ./fix-underspecified-getenv-prototype.patch
41 ];
42
43 outputs = [
44 "out"
45 "man"
46 "doc"
47 "info"
48 "perl"
49 ];
50
51 enableParallelBuilding = true;
52
53 postPatch = ''
54 # BASH_PROG gets replaced with a path to the build bash which doesn't get automatically patched by patchShebangs
55 substituteInPlace contrib/gdiffmk/gdiffmk.sh \
56 --replace "@BASH_PROG@" "/bin/sh"
57 ''
58 + lib.optionalString enableHtml ''
59 substituteInPlace src/preproc/html/pre-html.cpp \
60 --replace "psselect" "${psutils}/bin/psselect" \
61 --replace "pnmcut" "${lib.getBin netpbm}/bin/pnmcut" \
62 --replace "pnmcrop" "${lib.getBin netpbm}/bin/pnmcrop" \
63 --replace "pnmtopng" "${lib.getBin netpbm}/bin/pnmtopng"
64 substituteInPlace tmac/www.tmac.in \
65 --replace "pnmcrop" "${lib.getBin netpbm}/bin/pnmcrop" \
66 --replace "pngtopnm" "${lib.getBin netpbm}/bin/pngtopnm" \
67 --replace "@PNMTOPS_NOSETPAGE@" "${lib.getBin netpbm}/bin/pnmtops -nosetpage"
68 ''
69 + lib.optionalString (enableGhostscript || enableHtml) ''
70 substituteInPlace contrib/pdfmark/pdfroff.sh \
71 --replace '$GROFF_GHOSTSCRIPT_INTERPRETER' "${lib.getBin ghostscript}/bin/gs" \
72 --replace '$GROFF_AWK_INTERPRETER' "${lib.getBin gawk}/bin/gawk"
73 '';
74
75 strictDeps = true;
76 nativeBuildInputs = [
77 autoreconfHook
78 pkg-config
79 texinfo
80 ]
81 # Required due to the patch that changes .ypp files.
82 ++ lib.optional (stdenv.cc.isClang && lib.versionAtLeast stdenv.cc.version "9") bison;
83 buildInputs = [
84 perl
85 bashNonInteractive
86 ]
87 ++ lib.optionals enableGhostscript [
88 ghostscript
89 gawk
90 libX11
91 libXaw
92 libXt
93 libXmu
94 ]
95 ++ lib.optionals enableHtml [
96 psutils
97 netpbm
98 ]
99 ++ lib.optionals enableIconv [ iconv ]
100 ++ lib.optionals enableLibuchardet [ libuchardet ];
101
102 # Builds running without a chroot environment may detect the presence
103 # of /usr/X11 in the host system, leading to an impure build of the
104 # package. To avoid this issue, X11 support is explicitly disabled.
105 configureFlags =
106 lib.optionals (!enableGhostscript) [
107 "--without-x"
108 ]
109 ++ [
110 "ac_cv_path_PERL=${buildPackages.perl}/bin/perl"
111 ]
112 ++ lib.optionals enableGhostscript [
113 "--with-gs=${lib.getBin ghostscript}/bin/gs"
114 "--with-awk=${lib.getBin gawk}/bin/gawk"
115 "--with-appresdir=${placeholder "out"}/lib/X11/app-defaults"
116 ]
117 ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
118 "gl_cv_func_signbit=yes"
119 ];
120
121 makeFlags = lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [
122 # Trick to get the build system find the proper 'native' groff
123 # http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html
124 "GROFF_BIN_PATH=${buildPackages.groff}/bin"
125 "GROFFBIN=${buildPackages.groff}/bin/groff"
126 ];
127
128 doCheck = true;
129
130 postInstall = ''
131 for f in 'man.local' 'mdoc.local'; do
132 cat '${./site.tmac}' >>"$out/share/groff/site-tmac/$f"
133 done
134
135 moveToOutput bin/gropdf $perl
136 moveToOutput bin/pdfmom $perl
137 moveToOutput bin/roff2text $perl
138 moveToOutput bin/roff2pdf $perl
139 moveToOutput bin/roff2ps $perl
140 moveToOutput bin/roff2dvi $perl
141 moveToOutput bin/roff2ps $perl
142 moveToOutput bin/roff2html $perl
143 moveToOutput bin/glilypond $perl
144 moveToOutput bin/mmroff $perl
145 moveToOutput bin/roff2x $perl
146 moveToOutput bin/afmtodit $perl
147 moveToOutput bin/gperl $perl
148 moveToOutput bin/chem $perl
149
150 moveToOutput bin/gpinyin $perl
151 moveToOutput lib/groff/gpinyin $perl
152 substituteInPlace $perl/bin/gpinyin \
153 --replace $out/lib/groff/gpinyin $perl/lib/groff/gpinyin
154
155 moveToOutput bin/grog $perl
156 moveToOutput lib/groff/grog $perl
157 substituteInPlace $perl/bin/grog \
158 --replace $out/lib/groff/grog $perl/lib/groff/grog
159
160 find $perl/ -type f -print0 | xargs --null sed -i 's|${buildPackages.perl}|${perl}|'
161 '';
162
163 meta = {
164 homepage = "https://www.gnu.org/software/groff/";
165 description = "GNU Troff, a typesetting package that reads plain text and produces formatted output";
166 license = lib.licenses.gpl3Plus;
167 platforms = lib.platforms.all;
168 maintainers = with lib.maintainers; [ pSub ];
169
170 longDescription = ''
171 groff is the GNU implementation of troff, a document formatting
172 system. Included in this release are implementations of troff,
173 pic, eqn, tbl, grn, refer, -man, -mdoc, -mom, and -ms macros,
174 and drivers for PostScript, TeX dvi format, HP LaserJet 4
175 printers, Canon CAPSL printers, HTML and XHTML format (beta
176 status), and typewriter-like devices. Also included is a
177 modified version of the Berkeley -me macros, the enhanced
178 version gxditview of the X11 xditview previewer, and an
179 implementation of the -mm macros.
180 '';
181
182 outputsToInstall = [
183 "out"
184 "perl"
185 ];
186 };
187}