libreoffice: wrapper.nix rewrite
Cleanup the unwrapped derivation's postInstall. Delete wrapper.sh, and put it's contents in the wrapped derivation via configurable `makeWrapper`. Also, always install dolphin templates in the unwrapped derivation.
This commit is contained in:
parent
2e8194d47b
commit
3966519d12
4 changed files with 175 additions and 96 deletions
|
@ -1,6 +1,7 @@
|
|||
{ stdenv
|
||||
, fetchurl
|
||||
, lib
|
||||
, substituteAll
|
||||
, pam
|
||||
, python3
|
||||
, libxslt
|
||||
|
@ -88,7 +89,6 @@
|
|||
, gdb
|
||||
, commonsLogging
|
||||
, librdf_rasqal
|
||||
, wrapGAppsHook
|
||||
, gnome
|
||||
, glib
|
||||
, ncurses
|
||||
|
@ -102,15 +102,32 @@
|
|||
, mkDerivation ? null
|
||||
, qtbase ? null
|
||||
, qtx11extras ? null
|
||||
, qtwayland ? null
|
||||
, ki18n ? null
|
||||
, kconfig ? null
|
||||
, kcoreaddons ? null
|
||||
, kio ? null
|
||||
, kwindowsystem ? null
|
||||
, wrapQtAppsHook ? null
|
||||
, variant ? "fresh"
|
||||
, symlinkJoin
|
||||
, postgresql
|
||||
# The rest are used only in passthru, for the wrapper
|
||||
, kauth ? null
|
||||
, kcompletion ? null
|
||||
, kconfigwidgets ? null
|
||||
, kglobalaccel ? null
|
||||
, kitemviews ? null
|
||||
, knotifications ? null
|
||||
, ktextwidgets ? null
|
||||
, kwidgetsaddons ? null
|
||||
, kxmlgui ? null
|
||||
, phonon ? null
|
||||
, qtdeclarative ? null
|
||||
, qtquickcontrols ? null
|
||||
, qtsvg ? null
|
||||
, qttools ? null
|
||||
, solid ? null
|
||||
, sonnet ? null
|
||||
} @ args:
|
||||
|
||||
assert builtins.elem variant [ "fresh" "still" ];
|
||||
|
@ -354,33 +371,24 @@ in
|
|||
|
||||
# It installs only things to $out/lib/libreoffice
|
||||
postInstall = ''
|
||||
mkdir -p $out/bin $out/share/desktop
|
||||
|
||||
mkdir -p "$out/share/gsettings-schemas/collected-for-libreoffice/glib-2.0/schemas/"
|
||||
|
||||
for a in sbase scalc sdraw smath swriter simpress soffice unopkg; do
|
||||
ln -s $out/lib/libreoffice/program/$a $out/bin/$a
|
||||
done
|
||||
|
||||
ln -s $out/bin/soffice $out/bin/libreoffice
|
||||
mkdir -p $out/share
|
||||
ln -s $out/lib/libreoffice/share/xdg $out/share/applications
|
||||
|
||||
for f in $out/share/applications/*.desktop; do
|
||||
substituteInPlace "$f" \
|
||||
--replace "Exec=libreoffice${major}.${minor}" "Exec=libreoffice"
|
||||
done
|
||||
|
||||
cp -r sysui/desktop/icons "$out/share"
|
||||
sed -re 's@Icon=libreoffice(dev)?[0-9.]*-?@Icon=@' -i "$out/share/applications/"*.desktop
|
||||
|
||||
# Install dolphin templates, like debian does
|
||||
install -D extras/source/shellnew/soffice.* --target-directory="$out/share/templates/.source"
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Writer"; ext="odt"; type="text"; }} $out/share/templates/soffice.odt.desktop
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Calc"; ext="ods"; type="spreadsheet"; }} $out/share/templates/soffice.ods.desktop
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Impress"; ext="odp"; type="presentation";}} $out/share/templates/soffice.odp.desktop
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Draw"; ext="odg"; type="drawing"; }} $out/share/templates/soffice.odg.desktop
|
||||
|
||||
mkdir -p $dev
|
||||
cp -r include $dev
|
||||
'' + optionalString kdeIntegration ''
|
||||
for prog in $out/bin/*; do
|
||||
wrapQtApp $prog
|
||||
done
|
||||
'';
|
||||
|
||||
# Wrapping is done in ./wrapper.nix
|
||||
dontWrapQtApps = true;
|
||||
|
||||
configureFlags = [
|
||||
|
@ -464,8 +472,7 @@ in
|
|||
jdk17
|
||||
libtool
|
||||
pkg-config
|
||||
]
|
||||
++ [ (if kdeIntegration then wrapQtAppsHook else wrapGAppsHook) ];
|
||||
];
|
||||
|
||||
buildInputs = with xorg; [
|
||||
ArchiveZip
|
||||
|
@ -557,20 +564,56 @@ in
|
|||
zip
|
||||
zlib
|
||||
]
|
||||
++ (with gst_all_1; [
|
||||
gst-libav
|
||||
gst-plugins-bad
|
||||
gst-plugins-base
|
||||
gst-plugins-good
|
||||
gst-plugins-ugly
|
||||
gstreamer
|
||||
])
|
||||
++ passthru.gst_packages
|
||||
++ optionals kdeIntegration [ qtbase qtx11extras kcoreaddons kio ]
|
||||
++ optionals (lib.versionAtLeast (lib.versions.majorMinor version) "7.4") [ libwebp ];
|
||||
|
||||
passthru = {
|
||||
inherit srcs;
|
||||
jdk = jre';
|
||||
inherit kdeIntegration;
|
||||
# For the wrapper.nix
|
||||
inherit gtk3;
|
||||
# Although present in qtPackages, we need qtbase.qtPluginPrefix and
|
||||
# qtbase.qtQmlPrefix
|
||||
inherit qtbase;
|
||||
gst_packages = with gst_all_1; [
|
||||
gst-libav
|
||||
gst-plugins-bad
|
||||
gst-plugins-base
|
||||
gst-plugins-good
|
||||
gst-plugins-ugly
|
||||
gstreamer
|
||||
];
|
||||
qmlPackages = [
|
||||
ki18n
|
||||
knotifications
|
||||
qtdeclarative
|
||||
qtquickcontrols
|
||||
qtwayland
|
||||
solid
|
||||
sonnet
|
||||
];
|
||||
qtPackages = [
|
||||
kauth
|
||||
kcompletion
|
||||
kconfigwidgets
|
||||
kglobalaccel
|
||||
ki18n
|
||||
kio
|
||||
kitemviews
|
||||
ktextwidgets
|
||||
kwidgetsaddons
|
||||
kwindowsystem
|
||||
kxmlgui
|
||||
phonon
|
||||
qtbase
|
||||
qtdeclarative
|
||||
qtsvg
|
||||
qttools
|
||||
qtwayland
|
||||
sonnet
|
||||
];
|
||||
};
|
||||
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
|
|
@ -1,33 +1,101 @@
|
|||
{ lib, runCommand
|
||||
, libreoffice, dbus, bash, substituteAll
|
||||
, coreutils, gnugrep
|
||||
, dolphinTemplates ? true
|
||||
{ lib
|
||||
, stdenv
|
||||
# The unwrapped libreoffice derivation
|
||||
, unwrapped
|
||||
, makeWrapper
|
||||
, runCommand
|
||||
, substituteAll
|
||||
# For Emulating wrapGAppsHook
|
||||
, gsettings-desktop-schemas
|
||||
, hicolor-icon-theme
|
||||
, dconf
|
||||
, librsvg
|
||||
, gdk-pixbuf
|
||||
# Configuration options for the wrapper
|
||||
, extraMakeWrapperArgs ? []
|
||||
, dbusVerify ? stdenv.isLinux
|
||||
, dbus
|
||||
}:
|
||||
runCommand libreoffice.name {
|
||||
inherit (libreoffice) jdk meta;
|
||||
inherit coreutils dbus gnugrep libreoffice bash;
|
||||
|
||||
let
|
||||
makeWrapperArgs = builtins.concatStringsSep " " ([
|
||||
"--set" "GDK_PIXBUF_MODULE_FILE" "${librsvg}/${gdk-pixbuf.moduleDir}.cache"
|
||||
"--prefix" "GIO_EXTRA_MODULES" ":" "${lib.getLib dconf}/lib/gio/modules"
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "${unwrapped.gtk3}/share/gsettings-schemas/${unwrapped.gtk3.name}"
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "$out/share"
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "${gsettings-desktop-schemas}/share/gsettings-schemas/${gsettings-desktop-schemas.name}"
|
||||
"--prefix" "XDG_DATA_DIRS" ":" "${hicolor-icon-theme}/share"
|
||||
"--prefix" "GST_PLUGIN_SYSTEM_PATH_1_0" ":"
|
||||
"${lib.makeSearchPath "lib/girepository-1.0" unwrapped.gst_packages}"
|
||||
] ++ lib.optionals unwrapped.kdeIntegration [
|
||||
"--prefix" "QT_PLUGIN_PATH" ":" "${
|
||||
lib.makeSearchPath
|
||||
unwrapped.qtbase.qtPluginPrefix
|
||||
(builtins.map lib.getBin unwrapped.qtPackages)
|
||||
}"
|
||||
"--prefix" "QML2_IMPORT_PATH" ":" "${
|
||||
lib.makeSearchPath unwrapped.qtbase.qtQmlPrefix
|
||||
(builtins.map lib.getBin unwrapped.qmlPackages)
|
||||
}"
|
||||
] ++ [
|
||||
# Add dictionaries from all NIX_PROFILES
|
||||
"--run" (lib.escapeShellArg ''
|
||||
for PROFILE in $NIX_PROFILES; do
|
||||
HDIR="$PROFILE/share/hunspell"
|
||||
if [ -d "$HDIR" ]; then
|
||||
export DICPATH=$DICPATH''${DICPATH:+:}$HDIR
|
||||
fi
|
||||
done
|
||||
'')
|
||||
] ++ lib.optionals dbusVerify [
|
||||
# If no dbus is running, start a dedicated dbus daemon
|
||||
"--run" (lib.escapeShellArg ''
|
||||
if ! ( test -n "$DBUS_SESSION_BUS_ADDRESS" ); then
|
||||
dbus_tmp_dir="/run/user/$(id -u)/libreoffice-dbus"
|
||||
if ! test -d "$dbus_tmp_dir" && test -d "/run"; then
|
||||
mkdir -p "$dbus_tmp_dir"
|
||||
fi
|
||||
if ! test -d "$dbus_tmp_dir"; then
|
||||
dbus_tmp_dir="/tmp/libreoffice-$(id -u)/libreoffice-dbus"
|
||||
mkdir -p "$dbus_tmp_dir"
|
||||
fi
|
||||
dbus_socket_dir="$(mktemp -d -p "$dbus_tmp_dir")"
|
||||
"${dbus}"/bin/dbus-daemon \
|
||||
--nopidfile \
|
||||
--nofork \
|
||||
--config-file "${dbus}"/share/dbus-1/session.conf \
|
||||
--address "unix:path=$dbus_socket_dir/session" &> /dev/null &
|
||||
dbus_pid=$!
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=$dbus_socket_dir/session"
|
||||
fi
|
||||
'')
|
||||
] ++ [
|
||||
"--chdir" "${unwrapped}/lib/libreoffice/program"
|
||||
"--inherit-argv0"
|
||||
] ++ extraMakeWrapperArgs
|
||||
);
|
||||
in runCommand "${unwrapped.name}-wrapped" {
|
||||
inherit (unwrapped) meta;
|
||||
paths = [ unwrapped ];
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
passthru = {
|
||||
inherit unwrapped;
|
||||
# For backwards compatibility:
|
||||
libreoffice = lib.warn "libreoffice: Use the unwrapped attributed, using libreoffice.libreoffice is deprecated." unwrapped;
|
||||
inherit (unwrapped) kdeIntegration;
|
||||
};
|
||||
} (''
|
||||
mkdir -p "$out/bin"
|
||||
substituteAll "${./wrapper.sh}" "$out/bin/soffice"
|
||||
chmod a+x "$out/bin/soffice"
|
||||
|
||||
for i in $(ls "${libreoffice}/bin/"); do
|
||||
test "$i" = "soffice" || ln -s soffice "$out/bin/$(basename "$i")"
|
||||
ln -s ${unwrapped}/share $out/share
|
||||
ln -s ${unwrapped}/lib $out/lib
|
||||
for i in sbase scalc sdraw smath swriter simpress soffice unopkg; do
|
||||
makeWrapper ${unwrapped}/lib/libreoffice/program/$i $out/bin/$i ${makeWrapperArgs}
|
||||
'' + lib.optionalString dbusVerify ''
|
||||
# Delete the dbus socket directory after libreoffice quits
|
||||
sed -i 's/^exec -a "$0" //g' $out/bin/"$i"
|
||||
echo 'code="$?"' >> $out/bin/$i
|
||||
echo 'test -n "$dbus_socket_dir" && { rm -rf "$dbus_socket_dir"; kill $dbus_pid; }' >> $out/bin/$i
|
||||
echo 'exit "$code"' >> $out/bin/$i
|
||||
'' + ''
|
||||
done
|
||||
|
||||
mkdir -p "$out/share"
|
||||
ln -s "${libreoffice}/share"/* $out/share
|
||||
'' + lib.optionalString dolphinTemplates ''
|
||||
# Add templates to dolphin "Create new" menu - taken from debian
|
||||
|
||||
# We need to unpack the core source since the necessary files aren't available in the libreoffice output
|
||||
unpackFile "${libreoffice.src}"
|
||||
|
||||
install -D "${libreoffice.name}"/extras/source/shellnew/soffice.* --target-directory="$out/share/templates/.source"
|
||||
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Writer"; ext="odt"; type="text"; }} $out/share/templates/soffice.odt.desktop
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Calc"; ext="ods"; type="spreadsheet"; }} $out/share/templates/soffice.ods.desktop
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Impress"; ext="odp"; type="presentation";}} $out/share/templates/soffice.odp.desktop
|
||||
cp ${substituteAll {src = ./soffice-template.desktop; app="Draw"; ext="odg"; type="drawing"; }} $out/share/templates/soffice.odg.desktop
|
||||
'')
|
||||
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#!@bash@/bin/bash
|
||||
export JAVA_HOME="${JAVA_HOME:-@jdk@}"
|
||||
#export SAL_USE_VCLPLUGIN="${SAL_USE_VCLPLUGIN:-gen}"
|
||||
|
||||
if "@coreutils@"/bin/uname | "@gnugrep@"/bin/grep Linux > /dev/null &&
|
||||
! ( test -n "$DBUS_SESSION_BUS_ADDRESS" ); then
|
||||
dbus_tmp_dir="/run/user/$(id -u)/libreoffice-dbus"
|
||||
if ! test -d "$dbus_tmp_dir" && test -d "/run"; then
|
||||
mkdir -p "$dbus_tmp_dir"
|
||||
fi
|
||||
if ! test -d "$dbus_tmp_dir"; then
|
||||
dbus_tmp_dir="/tmp/libreoffice-$(id -u)/libreoffice-dbus"
|
||||
mkdir -p "$dbus_tmp_dir"
|
||||
fi
|
||||
dbus_socket_dir="$(mktemp -d -p "$dbus_tmp_dir")"
|
||||
"@dbus@"/bin/dbus-daemon --nopidfile --nofork --config-file "@dbus@"/share/dbus-1/session.conf --address "unix:path=$dbus_socket_dir/session" &> /dev/null &
|
||||
dbus_pid=$!
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=$dbus_socket_dir/session"
|
||||
fi
|
||||
|
||||
for PROFILE in $NIX_PROFILES; do
|
||||
HDIR="$PROFILE/share/hunspell"
|
||||
if [ -d "$HDIR" ]; then
|
||||
export DICPATH=$DICPATH''${DICPATH:+:}$HDIR
|
||||
fi
|
||||
done
|
||||
|
||||
"@libreoffice@/bin/$("@coreutils@"/bin/basename "$0")" "$@"
|
||||
code="$?"
|
||||
|
||||
test -n "$dbus_socket_dir" && { rm -rf "$dbus_socket_dir"; kill $dbus_pid; }
|
||||
exit "$code"
|
|
@ -31159,7 +31159,7 @@ with pkgs;
|
|||
|
||||
libreoffice = hiPrio libreoffice-still;
|
||||
|
||||
libreoffice-unwrapped = (hiPrio libreoffice-still).libreoffice;
|
||||
libreoffice-unwrapped = libreoffice.unwrapped;
|
||||
|
||||
libreoffice-args = {
|
||||
inherit (perlPackages) ArchiveZip IOCompress;
|
||||
|
@ -31180,7 +31180,7 @@ with pkgs;
|
|||
};
|
||||
|
||||
libreoffice-qt = lowPrio (callPackage ../applications/office/libreoffice/wrapper.nix {
|
||||
libreoffice = libsForQt5.callPackage ../applications/office/libreoffice
|
||||
unwrapped = libsForQt5.callPackage ../applications/office/libreoffice
|
||||
(libreoffice-args // {
|
||||
kdeIntegration = true;
|
||||
variant = "fresh";
|
||||
|
@ -31188,20 +31188,20 @@ with pkgs;
|
|||
});
|
||||
|
||||
libreoffice-fresh = lowPrio (callPackage ../applications/office/libreoffice/wrapper.nix {
|
||||
libreoffice = callPackage ../applications/office/libreoffice
|
||||
unwrapped = callPackage ../applications/office/libreoffice
|
||||
(libreoffice-args // {
|
||||
variant = "fresh";
|
||||
});
|
||||
});
|
||||
libreoffice-fresh-unwrapped = libreoffice-fresh.libreoffice;
|
||||
libreoffice-fresh-unwrapped = libreoffice-fresh.unwrapped;
|
||||
|
||||
libreoffice-still = lowPrio (callPackage ../applications/office/libreoffice/wrapper.nix {
|
||||
libreoffice = callPackage ../applications/office/libreoffice
|
||||
unwrapped = callPackage ../applications/office/libreoffice
|
||||
(libreoffice-args // {
|
||||
variant = "still";
|
||||
});
|
||||
});
|
||||
libreoffice-still-unwrapped = libreoffice-still.libreoffice;
|
||||
libreoffice-still-unwrapped = libreoffice-still.unwrapped;
|
||||
|
||||
libresprite = callPackage ../applications/editors/libresprite {
|
||||
inherit (darwin.apple_sdk.frameworks) AppKit Cocoa Foundation;
|
||||
|
|
Loading…
Reference in a new issue