diff --git a/bsc/groff/0001-Fix-cross-compilation-by-looking-for-ar.patch b/bsc/groff/0001-Fix-cross-compilation-by-looking-for-ar.patch new file mode 100644 index 0000000..671293c --- /dev/null +++ b/bsc/groff/0001-Fix-cross-compilation-by-looking-for-ar.patch @@ -0,0 +1,46 @@ +From 1454525f70b43a6957b7c9e1870e997368787da3 Mon Sep 17 00:00:00 2001 +From: Samuel Dionne-Riel +Date: Fri, 8 Nov 2019 21:59:21 -0500 +Subject: [PATCH] Fix cross-compilation by looking for `ar`. + +--- + Makefile.am | 2 +- + configure.ac | 2 ++ + 2 files changed, 3 insertions(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index d18c49b8..b1b53338 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -494,7 +494,7 @@ CCC=@CXX@ + # INSTALL_INFO + # LN_S + +-AR=ar ++AR=@AR@ + ETAGS=etags + ETAGSFLAGS= + # Flag that tells etags to assume C++. +diff --git a/configure.ac b/configure.ac +index 28e75f17..2449b9f5 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -37,6 +37,7 @@ AC_CONFIG_AUX_DIR([build-aux]) + + AC_CONFIG_HEADERS([src/include/config.h:src/include/config.hin]) + AC_CONFIG_SRCDIR([src/roff/groff/groff.cpp]) ++AC_CONFIG_MACRO_DIR([m4]) + + AC_USE_SYSTEM_EXTENSIONS + +@@ -72,6 +73,7 @@ GROFF_DOC_CHECK + GROFF_MAKEINFO + GROFF_TEXI2DVI + AC_PROG_RANLIB ++AC_CHECK_TOOL([AR], [ar], [ar]) + GROFF_INSTALL_SH + GROFF_INSTALL_INFO + AC_PROG_INSTALL +-- +2.23.0 + diff --git a/bsc/groff/default.nix b/bsc/groff/default.nix new file mode 100644 index 0000000..a3397b4 --- /dev/null +++ b/bsc/groff/default.nix @@ -0,0 +1,127 @@ +{ stdenv, fetchurl, perl +, ghostscript #for postscript and html output +, psutils, netpbm #for html output +, buildPackages +, autoreconfHook +, pkgconfig +, texinfo +}: + +stdenv.mkDerivation rec { + pname = "groff"; + version = "1.22.4"; + + src = fetchurl { + url = "mirror://gnu/groff/${pname}-${version}.tar.gz"; + sha256 = "14q2mldnr1vx0l9lqp9v2f6iww24gj28iyh4j2211hyynx67p3p7"; + }; + + enableParallelBuilding = false; + + patches = [ + ./0001-Fix-cross-compilation-by-looking-for-ar.patch + ]; + + postPatch = stdenv.lib.optionalString (psutils != null) '' + substituteInPlace src/preproc/html/pre-html.cpp \ + --replace "psselect" "${psutils}/bin/psselect" + '' + stdenv.lib.optionalString (netpbm != null) '' + substituteInPlace src/preproc/html/pre-html.cpp \ + --replace "pnmcut" "${stdenv.lib.getBin netpbm}/bin/pnmcut" \ + --replace "pnmcrop" "${stdenv.lib.getBin netpbm}/bin/pnmcrop" \ + --replace "pnmtopng" "${stdenv.lib.getBin netpbm}/bin/pnmtopng" + substituteInPlace tmac/www.tmac.in \ + --replace "pnmcrop" "${stdenv.lib.getBin netpbm}/bin/pnmcrop" \ + --replace "pngtopnm" "${stdenv.lib.getBin netpbm}/bin/pngtopnm" \ + --replace "@PNMTOPS_NOSETPAGE@" "${stdenv.lib.getBin netpbm}/bin/pnmtops -nosetpage" + ''; + + buildInputs = [ ghostscript psutils netpbm perl ]; + nativeBuildInputs = [ autoreconfHook pkgconfig texinfo ]; + + # Builds running without a chroot environment may detect the presence + # of /usr/X11 in the host system, leading to an impure build of the + # package. To avoid this issue, X11 support is explicitly disabled. + # Note: If we ever want to *enable* X11 support, then we'll probably + # have to pass "--with-appresdir", too. + configureFlags = [ + "--without-x" + ] ++ stdenv.lib.optionals (ghostscript != null) [ + "--with-gs=${ghostscript}/bin/gs" + ] ++ stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + "ac_cv_path_PERL=${buildPackages.perl}/bin/perl" + ]; + + makeFlags = stdenv.lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ + # Trick to get the build system find the proper 'native' groff + # http://www.mail-archive.com/bug-groff@gnu.org/msg01335.html + "GROFF_BIN_PATH=${buildPackages.groff}/bin" + "GROFFBIN=${buildPackages.groff}/bin/groff" + ]; + + doCheck = true; + + postInstall = '' + for f in 'man.local' 'mdoc.local'; do + cat '${./site.tmac}' >>"$out/share/groff/site-tmac/$f" + done + + moveToOutput bin/gropdf $out + moveToOutput bin/pdfmom $out + moveToOutput bin/roff2text $out + moveToOutput bin/roff2pdf $out + moveToOutput bin/roff2ps $out + moveToOutput bin/roff2dvi $out + moveToOutput bin/roff2ps $out + moveToOutput bin/roff2html $out + moveToOutput bin/glilypond $out + moveToOutput bin/mmroff $out + moveToOutput bin/roff2x $out + moveToOutput bin/afmtodit $out + moveToOutput bin/gperl $out + moveToOutput bin/chem $out + moveToOutput share/groff/${version}/font/devpdf $out + + # idk if this is needed, but Fedora does it + moveToOutput share/groff/${version}/tmac/pdf.tmac $out + + moveToOutput bin/gpinyin $out + moveToOutput lib/groff/gpinyin $out + substituteInPlace $out/bin/gpinyin \ + --replace $out/lib/groff/gpinyin $out/lib/groff/gpinyin + + moveToOutput bin/groffer $out + moveToOutput lib/groff/groffer $out + substituteInPlace $out/bin/groffer \ + --replace $out/lib/groff/groffer $out/lib/groff/groffer + + moveToOutput bin/grog $out + moveToOutput lib/groff/grog $out + substituteInPlace $out/bin/grog \ + --replace $out/lib/groff/grog $out/lib/groff/grog + + '' + stdenv.lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' + find $out/ -type f -print0 | xargs --null sed -i 's|${buildPackages.perl}|${perl}|' + ''; + + meta = with stdenv.lib; { + homepage = "https://www.gnu.org/software/groff/"; + description = "GNU Troff, a typesetting package that reads plain text and produces formatted output"; + license = licenses.gpl3Plus; + platforms = platforms.all; + maintainers = with maintainers; [ pSub ]; + + longDescription = '' + groff is the GNU implementation of troff, a document formatting + system. Included in this release are implementations of troff, + pic, eqn, tbl, grn, refer, -man, -mdoc, -mom, and -ms macros, + and drivers for PostScript, TeX dvi format, HP LaserJet 4 + printers, Canon CAPSL printers, HTML and XHTML format (beta + status), and typewriter-like devices. Also included is a + modified version of the Berkeley -me macros, the enhanced + version gxditview of the X11 xditview previewer, and an + implementation of the -mm macros. + ''; + + }; +} diff --git a/bsc/groff/site.tmac b/bsc/groff/site.tmac new file mode 100644 index 0000000..8ef1040 --- /dev/null +++ b/bsc/groff/site.tmac @@ -0,0 +1,16 @@ +. +.if n \{\ +. \" Character translations for non-keyboard +. \" characters - to make them searchable +. if '\*[.T]'utf8' \{\ +. char \- \N'45' +. char - \N'45' +. char ' \N'39' +. char \' \N'39' +. \} +. +. \" Shut off SGR by default (groff colors) +. \" Require GROFF_SGR envvar defined to turn it on +. if '\V[GROFF_SGR]'' \ +. output x X tty: sgr 0 +.\} diff --git a/overlay.nix b/overlay.nix index c695def..be660c5 100644 --- a/overlay.nix +++ b/overlay.nix @@ -150,6 +150,8 @@ let enableStatic = true; }; + groff = callPackage ./bsc/groff/default.nix { }; + nixtools = callPackage ./bsc/nixtools/default.nix { }; garlicTools = callPackage ./garlic/tools.nix {};