diff options
author | Jacek Galowicz <jacek@galowicz.de> | 2022-01-12 18:33:44 +0100 |
---|---|---|
committer | Jacek Galowicz <jacek@galowicz.de> | 2022-01-13 10:48:19 +0100 |
commit | 768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1 (patch) | |
tree | c9b4070b39df46e4f7c27fb0c06c86d1df56be20 /pkgs/tools/misc/pandoc-drawio-filter/default.nix | |
parent | d7c65f2c7ecdb9beb2f62979170000f4b74e70b3 (diff) | |
download | nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.tar nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.tar.gz nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.tar.bz2 nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.tar.lz nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.tar.xz nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.tar.zst nixpkgs-768523dd4327a9ec53ecf7ad7a5a9c0f5464e5c1.zip |
pandoc-drawio-filter: init at 1.0
Diffstat (limited to 'pkgs/tools/misc/pandoc-drawio-filter/default.nix')
-rw-r--r-- | pkgs/tools/misc/pandoc-drawio-filter/default.nix | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/pkgs/tools/misc/pandoc-drawio-filter/default.nix b/pkgs/tools/misc/pandoc-drawio-filter/default.nix new file mode 100644 index 00000000000..1279296143c --- /dev/null +++ b/pkgs/tools/misc/pandoc-drawio-filter/default.nix @@ -0,0 +1,78 @@ +{ buildPythonApplication +, drawio +, fetchFromGitHub +, lib +, pandoc +, pandocfilters +, runCommand +, runtimeShell +, texlive +, writeScriptBin +, xvfb-run +}: + +let + version = "1.1"; + + src = fetchFromGitHub { + owner = "tfc"; + repo = "pandoc-drawio-filter"; + rev = version; + sha256 = "sha256-2XJSAfxqEmmamWIAM3vZqi0mZjUUugmR3zWw8Imjadk="; + }; + + wrappedDrawio = writeScriptBin "drawio" '' + #!${runtimeShell} + + # Electron really wants a configuration directory to not die with: + # "Error: Failed to get 'appData' path" + # so we give it some temp dir as XDG_CONFIG_HOME + tmpdir=$(mktemp -d) + + function cleanup { + rm -rf "$tmpdir" + } + trap cleanup EXIT + + # Drawio needs to run in a virtual X session, because Electron + # refuses to work and dies with an unhelpful error message otherwise: + # "The futex facility returned an unexpected error code." + XDG_CONFIG_HOME="$tmpdir" ${xvfb-run}/bin/xvfb-run ${drawio}/bin/drawio $@ + ''; + + pandoc-drawio-filter = buildPythonApplication { + pname = "pandoc-drawio-filter"; + + inherit src version; + + propagatedBuildInputs = [ + wrappedDrawio + pandocfilters + ]; + + passthru.tests.example-doc = + let + env = { + nativeBuildInputs = [ + pandoc + pandoc-drawio-filter + texlive.combined.scheme-tetex + ]; + }; + in + runCommand "$pandoc-drawio-filter-example-doc.pdf" env '' + cp -r ${src}/example/* . + pandoc -F pandoc-drawio example.md -T pdf -o $out + ''; + + meta = with lib; { + homepage = "https://github.com/tfc/pandoc-drawio-filter"; + description = "Pandoc filter which converts draw.io diagrams to PDF"; + license = licenses.mit; + maintainers = with maintainers; [ tfc ]; + }; + }; + +in + +pandoc-drawio-filter |