about summary refs log tree commit diff
path: root/pkgs/applications/graphics/drawio
diff options
context:
space:
mode:
authorJacek Galowicz <jacek@galowicz.de>2022-05-19 11:12:08 +0200
committerGitHub <noreply@github.com>2022-05-19 11:12:08 +0200
commitf7897d42b26491c6679e9d5423ff7928067bc1c1 (patch)
tree0ee423bfed6691310cb9c7f25892dd047a442acf /pkgs/applications/graphics/drawio
parent5015c705a31e5057eb86d0a8f0dd3ecba886d089 (diff)
parent3e3d98cbb3327d46963f2fa6639e3d08b5dc8406 (diff)
Merge pull request #173589 from alyssais/drawio-headless
drawio-headless: extract from pandoc-drawio-filter
Diffstat (limited to 'pkgs/applications/graphics/drawio')
-rw-r--r--pkgs/applications/graphics/drawio/headless.nix36
1 files changed, 36 insertions, 0 deletions
diff --git a/pkgs/applications/graphics/drawio/headless.nix b/pkgs/applications/graphics/drawio/headless.nix
new file mode 100644
index 0000000000000..c70511fa6528c
--- /dev/null
+++ b/pkgs/applications/graphics/drawio/headless.nix
@@ -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 ];
+  };
+}