From 524315194c77563a3d57724aa41cffdfab1959df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Forsman?= Date: Sun, 22 Sep 2013 14:29:43 +0200 Subject: [PATCH] asciidoc: add support for matplotlib filter --- pkgs/tools/typesetting/asciidoc/default.nix | 18 ++++++++++++++++++ pkgs/top-level/all-packages.nix | 4 +++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/pkgs/tools/typesetting/asciidoc/default.nix b/pkgs/tools/typesetting/asciidoc/default.nix index b2d3d182610b..a381fb863eb2 100644 --- a/pkgs/tools/typesetting/asciidoc/default.nix +++ b/pkgs/tools/typesetting/asciidoc/default.nix @@ -4,12 +4,14 @@ , enableMscgenFilter ? false, mscgen ? null , enableDiagFilter ? false, blockdiag ? null, seqdiag ? null, actdiag ? null, nwdiag ? null , enableQrcodeFilter ? false, qrencode ? null +, enableMatplotlibFilter ? false, matplotlib ? null, numpy ? null }: assert (enableDitaaFilter || enableMscgenFilter || enableDiagFilter || enableQrcodeFilter) -> unzip != null; assert enableDitaaFilter -> jre != null; assert enableMscgenFilter -> mscgen != null; assert enableDiagFilter -> blockdiag != null && seqdiag != null && actdiag != null && nwdiag != null; +assert enableMatplotlibFilter -> matplotlib != null && numpy != null; let ditaaFilterSrc = fetchurl { @@ -33,6 +35,13 @@ let sha256 = "0h4bql1nb4y4fmg2yvlpfjhvy22ln8jsaxdr10f8bfcg5lr0zkxs"; }; + # 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}"; + sha256 = "0yfhkm2dr8gnp0fcg25x89hwiymkri2m5cyqzmzragzwj0hbmcf1"; + }; + in stdenv.mkDerivation rec { @@ -73,6 +82,15 @@ stdenv.mkDerivation rec { unzip -d "$out/etc/asciidoc/filters/qrcode" "${qrcodeFilterSrc}" sed -i -e "s|systemcmd('qrencode|systemcmd('${qrencode}/bin/qrencode|" \ "$out/etc/asciidoc/filters/qrcode/qrcode2img.py" + '' + optionalString enableMatplotlibFilter '' + echo "Extracting mpl (matplotlib) filter" + mkdir -p "$out/etc/asciidoc/filters/mpl" + tar xvf "${matplotlibFilterSrc}" -C "$out/etc/asciidoc/filters/mpl" --strip-components=1 + # Add matplotlib and numpy to sys.path + matplotlib_path="$(toPythonPath ${matplotlib})" + numpy_path="$(toPythonPath ${numpy})" + sed -i "/^import.*sys/asys.path.append(\"$matplotlib_path\"); sys.path.append(\"$numpy_path\");" \ + "$out/etc/asciidoc/filters/mpl/mplw.py" '' + '' for n in $(find "$out" . -name \*.py); do sed -i -e "s,^#![[:space:]]*/usr/bin/env python,#!${python}/bin/python,g" "$n" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 141434c0a0f8..8e4f2488f46b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -562,7 +562,9 @@ let mcelog = callPackage ../os-specific/linux/mcelog { }; - asciidoc = callPackage ../tools/typesetting/asciidoc { }; + asciidoc = callPackage ../tools/typesetting/asciidoc { + inherit (pythonPackages) matplotlib numpy; + }; autossh = callPackage ../tools/networking/autossh { };