drawio-headless: extract from pandoc-drawio-filter

This wrapper is useful independently of pandoc-drawio-filter — it's
useful in any other situation in which somebody might want to use
draw.io diagrams in a build process.

So, make it accessible from the top level to facilitate reuse.
This commit is contained in:
Alyssa Ross 2022-05-19 08:20:50 +00:00
parent 1d7db1b9e4
commit 3e3d98cbb3
No known key found for this signature in database
GPG Key ID: F9DBED4859B271C0
3 changed files with 39 additions and 21 deletions

View File

@ -0,0 +1,36 @@
{ lib, writeTextFile, runtimeShell, drawio, xvfb-run }:
writeTextFile {
name = "${drawio.pname}-headless-${drawio.version}";
executable = true;
destination = "/bin/drawio";
text = ''
#!${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 $@
'';
meta = with lib; {
description = "xvfb wrapper around drawio";
longDescription = ''
A wrapper around drawio for running in headless environments.
Runs drawio under xvfb-run, with configuration going to a temporary
directory.
'';
maintainers = with maintainers; [ qyliss tfc ];
};
}

View File

@ -1,5 +1,5 @@
{ buildPythonApplication { buildPythonApplication
, drawio , drawio-headless
, fetchFromGitHub , fetchFromGitHub
, lib , lib
, pandoc , pandoc
@ -21,32 +21,13 @@ let
sha256 = "sha256-2XJSAfxqEmmamWIAM3vZqi0mZjUUugmR3zWw8Imjadk="; 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 { pandoc-drawio-filter = buildPythonApplication {
pname = "pandoc-drawio-filter"; pname = "pandoc-drawio-filter";
inherit src version; inherit src version;
propagatedBuildInputs = [ propagatedBuildInputs = [
wrappedDrawio drawio-headless
pandocfilters pandocfilters
]; ];

View File

@ -25860,6 +25860,7 @@ with pkgs;
drawing = callPackage ../applications/graphics/drawing { }; drawing = callPackage ../applications/graphics/drawing { };
drawio = callPackage ../applications/graphics/drawio {}; drawio = callPackage ../applications/graphics/drawio {};
drawio-headless = callPackage ../applications/graphics/drawio/headless.nix { };
drawpile = libsForQt5.callPackage ../applications/graphics/drawpile { }; drawpile = libsForQt5.callPackage ../applications/graphics/drawpile { };
drawpile-server-headless = libsForQt5.callPackage ../applications/graphics/drawpile { drawpile-server-headless = libsForQt5.callPackage ../applications/graphics/drawpile {