about summary refs log tree commit diff
path: root/pkgs/applications/misc/openlp/default.nix
blob: a075a9bec6f5f5f2e6b887cb43dd2cb981374fcf (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# This file contains all runtime glue: Bindings to optional runtime dependencies
# for pdfSupport, presentationSupport, and media playback.
{ lib, mkDerivation, wrapGAppsHook, python3Packages

# qt deps
, qtbase, qtmultimedia

# optional deps
, pdfSupport ? false, mupdf  # alternatively could use ghostscript
, presentationSupport ? false, libreoffice-unwrapped
, vlcSupport ? false
, gstreamerSupport ? false, gst_all_1, gstPlugins ? (gst: [
    gst.gst-plugins-base
    gst.gst-plugins-good
    gst.gst-plugins-bad
    gst.gst-plugins-ugly
  ])

#, enableMySql ? false      # Untested. If interested, contact maintainer.
#, enablePostgreSql ? false # Untested. If interested, contact maintainer.
#, enableJenkinsApi ? false # Untested. If interested, contact maintainer.
}:

let p = gstPlugins gst_all_1;
# If gstreamer is activated but no plugins are given, it will at runtime
# create the false illusion of being usable.
in assert gstreamerSupport -> (builtins.isList p && builtins.length p > 0);

let
  # optional packages
  libreofficePath = "${libreoffice-unwrapped}/lib/libreoffice/program";

  # lib functions
  inherit (lib.lists) optional optionals;
  wrapSetVar = var: ''--set ${var} "''$${var}"'';

  # base pkg/lib
  baseLib = python3Packages.callPackage ./lib.nix { };
in mkDerivation {
  pname = baseLib.pname + lib.optionalString (pdfSupport && presentationSupport && vlcSupport && gstreamerSupport) "-full";
  inherit (baseLib) version src;

  nativeBuildInputs = [ python3Packages.wrapPython wrapGAppsHook ];
  buildInputs = [ qtbase ] ++ optionals gstreamerSupport
    ([ qtmultimedia.bin gst_all_1.gstreamer ] ++ gstPlugins gst_all_1);
  propagatedBuildInputs = optional pdfSupport mupdf
    ++ optional presentationSupport libreoffice-unwrapped;
  pythonPath = [ baseLib ] ++ optional vlcSupport python3Packages.python-vlc;
    # ++ optional enableMySql mysql-connector  # Untested. If interested, contact maintainer.
    # ++ optional enablePostgreSql psycopg2    # Untested. If interested, contact maintainer.
    # ++ optional enableJenkinsApi jenkinsapi  # Untested. If interested, contact maintainer.

  PYTHONPATH = libreofficePath;
  URE_BOOTSTRAP = "vnd.sun.star.pathname:${libreofficePath}/fundamentalrc";
  UNO_PATH = libreofficePath;
  LD_LIBRARY_PATH = libreofficePath;
  JAVA_HOME = "${libreoffice-unwrapped.jdk.home}";

  dontWrapQtApps = true;
  dontWrapGApps = true;

  # defined in gappsWrapperHook
  wrapPrefixVariables = optionals presentationSupport
    [ "PYTHONPATH" "LD_LIBRARY_PATH" "JAVA_HOME" ];
  makeWrapperArgs = [
    "\${gappsWrapperArgs[@]}"
    "\${qtWrapperArgs[@]}"
  ] ++ optionals presentationSupport
    ([ "--prefix PATH : ${libreoffice-unwrapped}/bin" ]
      ++ map wrapSetVar [ "URE_BOOTSTRAP" "UNO_PATH" ]);

  installPhase = ''
    install -D openlp.py $out/bin/openlp
  '';

  preFixup = ''
    wrapPythonPrograms
  '';

  meta = baseLib.meta // {
    hydraPlatforms = [ ]; # this is only the wrapper; baseLib gets built
  };

  passthru = {
    inherit baseLib;
  };
}