From 0350bd3b4853e2b4e3aa4038129073c195c8bef2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Sat, 28 Sep 2013 00:38:28 +0200 Subject: [PATCH 1/5] dblatex: add missing dependencies imagemagick, transfig, inkscape, fontconfig and ghostscript was missing. And pass --use-python-path at install time so that script shebangs end up with #!/path/to/python instead of #!/path/to/env python. --- .../tools/typesetting/tex/dblatex/default.nix | 34 ++++++++++++++++--- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/pkgs/tools/typesetting/tex/dblatex/default.nix b/pkgs/tools/typesetting/tex/dblatex/default.nix index fa4746a562e..f95621be6f5 100644 --- a/pkgs/tools/typesetting/tex/dblatex/default.nix +++ b/pkgs/tools/typesetting/tex/dblatex/default.nix @@ -1,4 +1,5 @@ -{ stdenv, fetchurl, python, libxslt, tetex }: +{ stdenv, fetchurl, python, libxslt, tetex, imagemagick, transfig, inkscape +, fontconfig, ghostscript }: stdenv.mkDerivation rec { name = "dblatex-0.3.4"; @@ -8,15 +9,38 @@ stdenv.mkDerivation rec { sha256 = "120w3wm07qx0k1grgdhjwm2vpwil71icshjvqznskp1f6ggch290"; }; + buildInputs = [ python libxslt tetex imagemagick transfig ]; + + # TODO: dblatex tries to execute texindy command, but nixpkgs doesn't have + # that yet. In Ubuntu, texindy is a part of the xindy package. + preConfigure = '' + for file in $(find -name "*.py"); do + sed -e 's|cmd = \["xsltproc|cmd = \["${libxslt}/bin/xsltproc|g' \ + -e 's|Popen(\["xsltproc|Popen(\["${libxslt}/bin/xsltproc|g' \ + -e 's|cmd = "convert|cmd = "${imagemagick}/bin/convert|g' \ + -e 's|cmd = "fig2dev|cmd = "${transfig}/bin/fig2dev|g' \ + -e 's|cmd = \["texindy|cmd = ["nixpkgs_is_missing_texindy|g' \ + -e 's|cmd = \["ps2pdf|cmd = ["${ghostscript}/bin/ps2pdf|g' \ + -e 's|cmd = "inkscape|cmd = "${inkscape}/bin/inkscape|g' \ + -e 's|cmd = "epstopdf|cmd = "${tetex}/bin/epstopdf|g' \ + -e 's|cmd = \["makeindex|cmd = ["${tetex}/bin/makeindex|g' \ + -e 's|doc.program = "pdflatex"|doc.program = "${tetex}/bin/pdflatex"|g' \ + -e 's|self.program = "latex"|self.program = "${tetex}/bin/latex"|g' \ + -e 's|Popen("pdflatex|Popen("${tetex}/bin/pdflatex|g' \ + -e 's|"fc-match"|"${fontconfig}/bin/fc-match"|g' \ + -e 's|"fc-list"|"${fontconfig}/bin/fc-list"|g' \ + -i "$file" + done + + sed -i 's|self.install_layout == "deb"|False|' setup.py + ''; + buildPhase = "true"; installPhase = '' - sed -i 's|self.install_layout == "deb"|False|' setup.py - python ./setup.py install --prefix=$out + python ./setup.py install --prefix="$out" --use-python-path --verbose ''; - buildInputs = [ python libxslt tetex ]; - meta = { description = "A program to convert DocBook to DVI, PostScript or PDF via LaTeX or ConTeXt"; homepage = http://dblatex.sourceforge.net/; From 48d3c123048f483a9772ff1f093cbb2d8225f2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Sat, 28 Sep 2013 19:25:25 +0200 Subject: [PATCH 2/5] lilypond: add missing ghostscript path to wrapper --- pkgs/misc/lilypond/default.nix | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkgs/misc/lilypond/default.nix b/pkgs/misc/lilypond/default.nix index 6d5d87faad6..2b6606faf3b 100644 --- a/pkgs/misc/lilypond/default.nix +++ b/pkgs/misc/lilypond/default.nix @@ -24,7 +24,10 @@ stdenv.mkDerivation rec{ ''; postInstall = '' - for f in $out/bin/*; do wrapProgram $f --set GUILE_AUTO_COMPILE 0; done + for f in "$out"/bin/*; do + wrapProgram "$f" --set GUILE_AUTO_COMPILE 0 \ + --set PATH "${ghostscript}/bin" + done ''; configureFlags = [ "--disable-documentation" "--with-ncsb-dir=${urwfonts}"]; From 7f28c64f110bd43136e90284e83cb55ebca70f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Sun, 29 Sep 2013 21:18:52 +0200 Subject: [PATCH 3/5] fop: new package fop is a XML formatter driven by XSL Formatting Objects (XSL-FO). Homepage: http://xmlgraphics.apache.org/fop/ --- pkgs/tools/typesetting/fop/default.nix | 56 ++++++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 58 insertions(+) create mode 100644 pkgs/tools/typesetting/fop/default.nix diff --git a/pkgs/tools/typesetting/fop/default.nix b/pkgs/tools/typesetting/fop/default.nix new file mode 100644 index 00000000000..bc4486ed49c --- /dev/null +++ b/pkgs/tools/typesetting/fop/default.nix @@ -0,0 +1,56 @@ +{ fetchurl, stdenv, ant, jdk }: + +stdenv.mkDerivation rec { + name = "fop-1.1"; + + src = fetchurl { + url = "http://apache.uib.no/xmlgraphics/fop/source/${name}-src.tar.gz"; + sha256 = "08i56d57w5dl5bqchr34x9165hvi5h4bhiflxhi0a4wd56rlq5jq"; + }; + + buildInputs = [ ant jdk ]; + + buildPhase = '' + ant + ''; + + installPhase = '' + mkdir -p "$out/bin" + mkdir -p "$out/lib" + mkdir -p "$out/share/doc/fop" + + cp build/*.jar lib/*.jar "$out/lib/" + cp -r README examples/ "$out/share/doc/fop/" + + # There is a fop script in the source archive, but it has many impurities. + # Instead of patching out 90 % of the script, we write our own. + cat > "$out/bin/fop" < Date: Fri, 27 Sep 2013 21:21:47 +0200 Subject: [PATCH 4/5] asciidoc: add/update meta attributes --- pkgs/tools/typesetting/asciidoc/default.nix | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix index fdbcf81090c..986d0d7a69c 100644 --- a/pkgs/tools/typesetting/asciidoc/default.nix +++ b/pkgs/tools/typesetting/asciidoc/default.nix @@ -161,14 +161,21 @@ stdenv.mkDerivation rec { preInstall = "mkdir -p $out/etc/vim"; - meta = { - homepage = "http://www.methods.co.nz/asciidoc/"; - description = "ASCII text-based document generation system"; - license = "GPLv2+"; - + meta = with stdenv.lib; { + description = "Text-based document generation system"; longDescription = '' - AsciiDoc is a text-based document generation system. AsciiDoc - input files can be translated to HTML and DocBook markups. + AsciiDoc is a text document format for writing notes, documentation, + articles, books, ebooks, slideshows, web pages, man pages and blogs. + AsciiDoc files can be translated to many formats including HTML, PDF, + EPUB, man page. + + AsciiDoc is highly configurable: both the AsciiDoc source file syntax and + the backend output markups (which can be almost any type of SGML/XML + markup) can be customized and extended by the user. ''; + homepage = "http://www.methods.co.nz/asciidoc/"; + license = licenses.gpl2Plus; + platforms = platforms.linux; + maintainers = [ maintainers.bjornfor ]; }; } From aef81d6eb68506426e2004d195125f89922e6a6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Mon, 23 Sep 2013 21:26:44 +0200 Subject: [PATCH 5/5] asciidoc: add missing dependencies The current asciidoc expression is impure; it relies on several tools to be found in PATH at runtime. This commit adds a enableStandardFeatures parameter that pulls in all dependencies and patches asciidoc to contain full paths to the tools. enableStandardFeatures defaults to true because asciidoc may attempt to call all tools in its default configuration. With all standard features, the closure size increases from 255 MiB to 1.5 GiB. Set enableStandardFeatures = false if you want a minimal asciidoc. --- pkgs/tools/typesetting/asciidoc/default.nix | 80 ++++++++++++++++++++- pkgs/top-level/all-packages.nix | 3 +- 2 files changed, 81 insertions(+), 2 deletions(-) diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix index 986d0d7a69c..8aba7182f5e 100644 --- a/pkgs/tools/typesetting/asciidoc/default.nix +++ b/pkgs/tools/typesetting/asciidoc/default.nix @@ -1,4 +1,25 @@ { fetchurl, stdenv, python + +, enableStandardFeatures ? true +, sourceHighlight ? null +, highlight ? null +, pygments ? null +, graphviz ? null +, tetex ? null +, dblatex ? null +, libxslt ? null +, w3m ? null +, lynx ? null +, imagemagick ? null +, lilypond ? null +, libxml2 ? null +, docbook_xml_dtd_45 ? null +, docbook5_xsl ? null +, docbook_xsl ? null +, fop ? null +# TODO: Package this: +#, epubcheck ? null + , unzip ? null # filters , enableDitaaFilter ? false, jre ? null @@ -12,6 +33,26 @@ , enableOdfBackend ? false }: +assert enableStandardFeatures -> + sourceHighlight != null && + highlight != null && + pygments != null && + graphviz != null && + tetex != null && + dblatex != null && + libxslt != null && + w3m != null && + lynx != null && + imagemagick != null && + lilypond != null && + libxml2 != null && + docbook_xml_dtd_45 != null && + docbook5_xsl != null && + docbook_xsl != null && + fop != null; +# TODO: Package this: +# epubcheck != null; + # filters assert (enableDitaaFilter || enableMscgenFilter || enableDiagFilter || enableQrcodeFilter || enableAafigureFilter) -> unzip != null; assert enableDitaaFilter -> jre != null; @@ -49,7 +90,7 @@ let sha256 = "0h4bql1nb4y4fmg2yvlpfjhvy22ln8jsaxdr10f8bfcg5lr0zkxs"; }; - # latest commit in master branch as per 2013-09-22 + # there are no archives or tags, using latest commit in master branch as per 2013-09-22 matplotlibFilterSrc = let commit = "75f0d009629f93f33fab04b83faca20cc35dd358"; in fetchurl rec { name = "mplw-${commit}.tar.gz"; url = "https://api.github.com/repos/lvv/mplw/tarball/${commit}"; @@ -151,11 +192,48 @@ stdenv.mkDerivation rec { # the odp backend already has that fix. Copy it here until fixed upstream. sed -i "s|'/etc/asciidoc/backends/odt/asciidoc.ott'|os.path.dirname(__file__),'asciidoc.ott'|" \ "$out/etc/asciidoc/backends/odt/a2x-backend.py" + '' + optionalString enableStandardFeatures '' + sed -e "s|dot|${graphviz}/bin/dot|g" \ + -e "s|neato|${graphviz}/bin/neato|g" \ + -e "s|twopi|${graphviz}/bin/circo|g" \ + -e "s|circo|${graphviz}/bin/circo|g" \ + -e "s|fdp|${graphviz}/bin/fdp|g" \ + -i "filters/graphviz/graphviz2png.py" + + sed -e "s|run('latex|run('${tetex}/bin/latex|g" \ + -e "s|cmd = 'dvipng'|cmd = '${tetex}/bin/dvipng'|g" \ + -i "filters/latex/latex2png.py" + + sed -e "s|run('abc2ly|run('${lilypond}/bin/abc2ly|g" \ + -e "s|run('lilypond|run('${lilypond}/bin/lilypond|g" \ + -e "s|run('convert|run('${imagemagick}/bin/convert|g" \ + -i "filters/music/music2png.py" + + sed -e 's|filter="source-highlight|filter="${sourceHighlight}/bin/source-highlight|' \ + -e 's|filter="highlight|filter="${highlight}/bin/highlight|' \ + -e 's|filter="pygmentize|filter="${pygments}/bin/pygmentize|' \ + -i "filters/source/source-highlight-filter.conf" + + # ENV is custom environment passed to programs that a2x invokes. Here we + # use it to work around an impurity in the tetex package; tetex tools + # cannot find their neighbours (e.g. pdflatex doesn't find mktextfm). + # We can remove PATH= when those impurities are fixed. + sed -e "s|^ENV =.*|ENV = dict(XML_CATALOG_FILES='${docbook_xml_dtd_45}/xml/dtd/docbook/catalog.xml ${docbook5_xsl}/xml/xsl/docbook/catalog.xml ${docbook_xsl}/xml/xsl/docbook/catalog.xml', PATH='${tetex}/bin')|" \ + -e "s|^ASCIIDOC =.*|ASCIIDOC = '$out/bin/asciidoc'|" \ + -e "s|^XSLTPROC =.*|XSLTPROC = '${libxslt}/bin/xsltproc'|" \ + -e "s|^DBLATEX =.*|DBLATEX = '${dblatex}/bin/dblatex'|" \ + -e "s|^FOP =.*|FOP = '${fop}/bin/fop'|" \ + -e "s|^W3M =.*|W3M = '${w3m}/bin/w3m'|" \ + -e "s|^LYNX =.*|LYNX = '${lynx}/bin/lynx'|" \ + -e "s|^XMLLINT =.*|XMLLINT = '${libxml2}/bin/xmllint'|" \ + -e "s|^EPUBCHECK =.*|EPUBCHECK = 'nixpkgs_is_missing_epubcheck'|" \ + -i a2x.py '' + '' for n in $(find "$out" . -name \*.py); do sed -i -e "s,^#![[:space:]]*.*/bin/env python,#!${python}/bin/python,g" "$n" chmod +x "$n" done + sed -i -e "s,/etc/vim,,g" Makefile.in ''; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index f3ff97d4429..e53f1b3368a 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -567,7 +567,8 @@ let mcelog = callPackage ../os-specific/linux/mcelog { }; asciidoc = callPackage ../tools/typesetting/asciidoc { - inherit (pythonPackages) matplotlib numpy aafigure recursivePthLoader; + inherit (pythonPackages) matplotlib numpy aafigure recursivePthLoader + pygments; }; autossh = callPackage ../tools/networking/autossh { };