Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ version, sha256, patches ? [] }:
2
3{ lib, stdenv, buildPackages, fetchurl, perl, xz, libintl, bash
4, gnulib
5
6# we are a dependency of gcc, this simplifies bootstraping
7, interactive ? false, ncurses, procps
8}:
9
10# Note: this package is used for bootstrapping fetchurl, and thus
11# cannot use fetchpatch! All mutable patches (generated by GitHub or
12# cgit) that are needed here should be included directly in Nixpkgs as
13# files.
14
15let
16 crossBuildTools = stdenv.hostPlatform != stdenv.buildPlatform;
17in
18
19with lib;
20
21stdenv.mkDerivation {
22 pname = "texinfo${optionalString interactive "-interactive"}";
23 inherit version;
24
25 src = fetchurl {
26 url = "mirror://gnu/texinfo/texinfo-${version}.tar.xz";
27 inherit sha256;
28 };
29
30 patches = patches ++ optional crossBuildTools ./cross-tools-flags.patch;
31
32 postPatch = ''
33 patchShebangs tp/maintain
34 ''
35 # This patch is needed for IEEE-standard long doubles on
36 # powerpc64; it does not apply cleanly to texinfo 5.x or
37 # earlier. It is merged upstream in texinfo 6.8.
38 + lib.optionalString (version == "6.7") ''
39 patch -p1 -d gnulib < ${gnulib.passthru.longdouble-redirect-patch}
40 '';
41
42 # ncurses is required to build `makedoc'
43 # this feature is introduced by the ./cross-tools-flags.patch
44 NATIVE_TOOLS_CFLAGS = if crossBuildTools then "-I${getDev buildPackages.ncurses}/include" else null;
45 NATIVE_TOOLS_LDFLAGS = if crossBuildTools then "-L${getLib buildPackages.ncurses}/lib" else null;
46
47 strictDeps = true;
48 enableParallelBuilding = true;
49
50 # A native compiler is needed to build tools needed at build time
51 depsBuildBuild = [ buildPackages.stdenv.cc perl ];
52
53 buildInputs = [ xz.bin bash libintl ]
54 ++ optionals stdenv.isSunOS [ libiconv gawk ]
55 ++ optional interactive ncurses;
56
57 configureFlags = [ "PERL=${buildPackages.perl}/bin/perl" ]
58 # Perl XS modules are difficult to cross-compile and texinfo has pure Perl
59 # fallbacks.
60 ++ optional crossBuildTools "--enable-perl-xs=no"
61 ++ lib.optional stdenv.isSunOS "AWK=${gawk}/bin/awk";
62
63 installFlags = [ "TEXMF=$(out)/texmf-dist" ];
64 installTargets = [ "install" "install-tex" ];
65
66 nativeCheckInputs = [ procps ];
67
68 doCheck = interactive
69 && !stdenv.isDarwin
70 && !stdenv.isSunOS; # flaky
71
72 checkFlags = lib.optionals (!stdenv.hostPlatform.isMusl && lib.versionOlder version "7") [
73 # Test is known to fail on various locales on texinfo-6.8:
74 # https://lists.gnu.org/r/bug-texinfo/2021-07/msg00012.html
75 "XFAIL_TESTS=test_scripts/layout_formatting_fr_icons.sh"
76 ];
77
78 postFixup = optionalString crossBuildTools ''
79 for f in "$out"/bin/{pod2texi,texi2any}; do
80 substituteInPlace "$f" \
81 --replace ${buildPackages.perl}/bin/perl ${perl}/bin/perl
82 done
83 '';
84
85 meta = {
86 description = "The GNU documentation system";
87 homepage = "https://www.gnu.org/software/texinfo/";
88 changelog = "https://git.savannah.gnu.org/cgit/texinfo.git/plain/NEWS";
89 license = licenses.gpl3Plus;
90 platforms = platforms.all;
91 maintainers = with maintainers; [ vrthra oxij ];
92 # see comment above in patches section
93 broken = stdenv.hostPlatform.isPower64 && lib.strings.versionOlder version "6.0";
94
95 longDescription = ''
96 Texinfo is the official documentation format of the GNU project.
97 It was invented by Richard Stallman and Bob Chassell many years
98 ago, loosely based on Brian Reid's Scribe and other formatting
99 languages of the time. It is used by many non-GNU projects as
100 well.
101
102 Texinfo uses a single source file to produce output in a number
103 of formats, both online and printed (dvi, html, info, pdf, xml,
104 etc.). This means that instead of writing different documents
105 for online information and another for a printed manual, you
106 need write only one document. And when the work is revised, you
107 need revise only that one document. The Texinfo system is
108 well-integrated with GNU Emacs.
109 '';
110 branch = version;
111 };
112}