summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2022-05-19 08:20:50 +0000
committerAlyssa Ross <hi@alyssa.is>2022-06-04 21:26:02 +0000
commit8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2 (patch)
tree7521cd4d69922f1dd64bc54b1e0de84eec3635ee
parent24b53a625832413f7d70a5ebf14a8a7b222bcf74 (diff)
downloadnixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.tar
nixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.tar.gz
nixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.tar.bz2
nixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.tar.lz
nixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.tar.xz
nixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.tar.zst
nixpkgs-8b9edf1e0fa01a9de7db6ead1b7b28f23b91b3e2.zip
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.

(cherry picked from commit 3e3d98cbb3327d46963f2fa6639e3d08b5dc8406)
Signed-off-by: Alyssa Ross <hi@alyssa.is>
-rw-r--r--pkgs/applications/graphics/drawio/headless.nix36
-rw-r--r--pkgs/tools/misc/pandoc-drawio-filter/default.nix23
-rw-r--r--pkgs/top-level/all-packages.nix1
3 files changed, 39 insertions, 21 deletions
diff --git a/pkgs/applications/graphics/drawio/headless.nix b/pkgs/applications/graphics/drawio/headless.nix
new file mode 100644
index 00000000000..c70511fa652
--- /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 ];
+  };
+}
diff --git a/pkgs/tools/misc/pandoc-drawio-filter/default.nix b/pkgs/tools/misc/pandoc-drawio-filter/default.nix
index 1279296143c..73dd658dfb1 100644
--- a/pkgs/tools/misc/pandoc-drawio-filter/default.nix
+++ b/pkgs/tools/misc/pandoc-drawio-filter/default.nix
@@ -1,5 +1,5 @@
 { buildPythonApplication
-, drawio
+, drawio-headless
 , fetchFromGitHub
 , lib
 , pandoc
@@ -21,32 +21,13 @@ let
     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
+      drawio-headless
       pandocfilters
     ];
 
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 0bd1d924d51..56155ca70a7 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -25850,6 +25850,7 @@ with pkgs;
   drawing = callPackage ../applications/graphics/drawing { };
 
   drawio = callPackage ../applications/graphics/drawio {};
+  drawio-headless = callPackage ../applications/graphics/drawio/headless.nix { };
 
   drawpile = libsForQt5.callPackage ../applications/graphics/drawpile { };
   drawpile-server-headless = libsForQt5.callPackage ../applications/graphics/drawpile {