3 # The unwrapped libreoffice derivation
8 # For Emulating wrapGAppsHook3
9 , gsettings-desktop-schemas
14 # some scripts need these when used in conjuction with firejail
17 # Configuration options for the wrapper
18 , extraMakeWrapperArgs ? []
19 , dbusVerify ? stdenv.hostPlatform.isLinux
24 inherit (unwrapped) version;
25 major = lib.versions.major version;
26 minor = lib.versions.minor version;
28 makeWrapperArgs = builtins.concatStringsSep " " ([
29 "--set" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.moduleDir}.cache"
30 "--prefix" "GIO_EXTRA_MODULES" ":" "${lib.getLib dconf}/lib/gio/modules"
31 "--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk3}/share/gsettings-schemas/${unwrapped.gtk3.name}"
32 "--prefix" "XDG_DATA_DIRS" ":" "$out/share"
33 "--prefix" "XDG_DATA_DIRS" ":" "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
34 "--prefix" "XDG_DATA_DIRS" ":" "${hicolor-icon-theme}/share"
35 "--prefix" "GST_PLUGIN_SYSTEM_PATH_1_0" ":"
36 "${lib.makeSearchPath "lib/girepository-1.0" unwrapped.gst_packages}"
37 "--suffix" "PATH" ":" "${lib.makeBinPath [ coreutils gnugrep ]}"
38 ] ++ lib.optionals unwrapped.kdeIntegration [
39 "--prefix" "QT_PLUGIN_PATH" ":" "${
41 unwrapped.qtbase.qtPluginPrefix
42 (builtins.map lib.getBin unwrapped.qtPackages)
44 "--prefix" "QML2_IMPORT_PATH" ":" "${
45 lib.makeSearchPath unwrapped.qtbase.qtQmlPrefix
46 (builtins.map lib.getBin unwrapped.qmlPackages)
49 # Add dictionaries from all NIX_PROFILES
50 "--run" (lib.escapeShellArg ''
51 for PROFILE in $NIX_PROFILES; do
52 HU_DIR="$PROFILE/share/hunspell"
53 HY_DIR="$PROFILE/share/hyphen"
54 if [ -d "$HU_DIR" ]; then
55 export DICPATH=$DICPATH''${DICPATH:+:}$HU_DIR
57 if [ -d "$HY_DIR" ]; then
58 export DICPATH=$DICPATH''${DICPATH:+:}$HY_DIR
62 ] ++ lib.optionals dbusVerify [
63 # If no dbus is running, start a dedicated dbus daemon
64 "--run" (lib.escapeShellArg ''
65 if ! ( test -n "$DBUS_SESSION_BUS_ADDRESS" ); then
66 dbus_tmp_dir="/run/user/$(id -u)/libreoffice-dbus"
67 if ! test -d "$dbus_tmp_dir" && test -d "/run"; then
68 mkdir -p "$dbus_tmp_dir"
70 if ! test -d "$dbus_tmp_dir"; then
71 dbus_tmp_dir="/tmp/libreoffice-$(id -u)/libreoffice-dbus"
72 mkdir -p "$dbus_tmp_dir"
74 dbus_socket_dir="$(mktemp -d -p "$dbus_tmp_dir")"
75 "${dbus}"/bin/dbus-daemon \
78 --config-file "${dbus}"/share/dbus-1/session.conf \
79 --address "unix:path=$dbus_socket_dir/session" &> /dev/null &
81 export DBUS_SESSION_BUS_ADDRESS="unix:path=$dbus_socket_dir/session"
86 ] ++ extraMakeWrapperArgs
88 in runCommand "${unwrapped.name}-wrapped" {
89 inherit (unwrapped) meta;
90 paths = [ unwrapped ];
91 nativeBuildInputs = [ makeWrapper xorg.lndir ];
94 # For backwards compatibility:
95 libreoffice = lib.warn "libreoffice: Use the unwrapped attributed, using libreoffice.libreoffice is deprecated." unwrapped;
96 inherit (unwrapped) kdeIntegration;
100 for dir in ${unwrapped}/share/*; do
101 dirname="''${dir##*/}"
102 if [[ $dirname == "applications" ]]; then
103 cp -r $dir/ $out/share/
105 ln -s $dir $out/share/
108 for f in $out/share/applications/*.desktop; do
109 substituteInPlace "$f" \
110 --replace "Exec=libreoffice${major}.${minor}" "Exec=soffice"
114 mkdir -p $out/lib/libreoffice/program
115 lndir -silent ${unwrapped}/lib/libreoffice/program $out/lib/libreoffice/program
116 for i in sbase scalc sdraw smath swriter simpress soffice unopkg; do
117 # Delete the symlink created by lndir, and replace it by our wrapper
118 rm $out/lib/libreoffice/program/$i
120 ${unwrapped}/lib/libreoffice/program/$i \
121 $out/lib/libreoffice/program/$i \
123 '' + lib.optionalString dbusVerify ''
124 # Delete the dbus socket directory after libreoffice quits
125 sed -i 's/^exec -a "$0" //g' $out/lib/libreoffice/program/$i
126 echo 'code="$?"' >> $out/lib/libreoffice/program/$i
127 echo 'test -n "$dbus_socket_dir" && { rm -rf "$dbus_socket_dir"; kill $dbus_pid; }' >> $out/lib/libreoffice/program/$i
128 echo 'exit "$code"' >> $out/lib/libreoffice/program/$i
130 ln -s $out/lib/libreoffice/program/$i $out/bin/$i
132 # A symlink many users rely upon
133 ln -s $out/bin/soffice $out/bin/libreoffice