From ee4ed757274fe821392eb66ad5f2d2022ffa966c Mon Sep 17 00:00:00 2001 From: Michael Raitza Date: Thu, 23 Mar 2023 16:47:52 +0100 Subject: [PATCH] groff: Fix ghostscript and html output, add X11 support --- pkgs/tools/text/groff/default.nix | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkgs/tools/text/groff/default.nix b/pkgs/tools/text/groff/default.nix index f6adca208fcf..ae250f2efeea 100644 --- a/pkgs/tools/text/groff/default.nix +++ b/pkgs/tools/text/groff/default.nix @@ -1,5 +1,6 @@ { lib, stdenv, fetchurl, fetchpatch, perl -, enableGhostscript ? false, ghostscript # for postscript and html output +, enableGhostscript ? false +, ghostscript, gawk, libX11, libXaw, libXt, libXmu # for postscript and html output , enableHtml ? false, psutils, netpbm # for html output , enableIconv ? false, iconv , enableLibuchardet ? false, libuchardet # for detecting input file encoding in preconv(1) @@ -24,6 +25,7 @@ stdenv.mkDerivation rec { # Parallel build is failing for missing depends. Known upstream as: # https://savannah.gnu.org/bugs/?62084 + # fixed, planned release: 1.23.0 enableParallelBuilding = false; patches = [ @@ -47,10 +49,15 @@ stdenv.mkDerivation rec { --replace "pnmcut" "${lib.getBin netpbm}/bin/pnmcut" \ --replace "pnmcrop" "${lib.getBin netpbm}/bin/pnmcrop" \ --replace "pnmtopng" "${lib.getBin netpbm}/bin/pnmtopng" - substituteInPlace tmac/www.tmac \ + substituteInPlace tmac/www.tmac.in \ --replace "pnmcrop" "${lib.getBin netpbm}/bin/pnmcrop" \ --replace "pngtopnm" "${lib.getBin netpbm}/bin/pngtopnm" \ --replace "@PNMTOPS_NOSETPAGE@" "${lib.getBin netpbm}/bin/pnmtops -nosetpage" + substituteInPlace contrib/groffer/roff2.pl \ + --replace "'gs'" "'${lib.getBin ghostscript}/bin/gs'" + substituteInPlace contrib/pdfmark/pdfroff.sh \ + --replace '$GROFF_GHOSTSCRIPT_INTERPRETER' "${lib.getBin ghostscript}/bin/gs" \ + --replace '$GROFF_AWK_INTERPRETER' "${lib.getBin gawk}/bin/gawk" ''; strictDeps = true; @@ -58,7 +65,7 @@ stdenv.mkDerivation rec { # Required due to the patch that changes .ypp files. ++ lib.optional (stdenv.cc.isClang && lib.versionAtLeast stdenv.cc.version "9") bison; buildInputs = [ perl bash ] - ++ lib.optionals enableGhostscript [ ghostscript ] + ++ lib.optionals enableGhostscript [ ghostscript gawk libX11 libXaw libXt libXmu ] ++ lib.optionals enableHtml [ psutils netpbm ] ++ lib.optionals enableIconv [ iconv ] ++ lib.optionals enableLibuchardet [ libuchardet ]; @@ -66,13 +73,14 @@ stdenv.mkDerivation rec { # 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 = [ + configureFlags = lib.optionals (!enableGhostscript) [ "--without-x" + ] ++ [ "ac_cv_path_PERL=${buildPackages.perl}/bin/perl" ] ++ lib.optionals enableGhostscript [ - "--with-gs=${ghostscript}/bin/gs" + "--with-gs=${lib.getBin ghostscript}/bin/gs" + "--with-awk=${lib.getBin gawk}/bin/gawk" + "--with-appresdir=${placeholder "out"}/lib/X11/app-defaults" ] ++ lib.optionals (stdenv.buildPlatform != stdenv.hostPlatform) [ "gl_cv_func_signbit=yes" ];