libreoffice: fix -qt build

main
Peter Hoeg 2 years ago
parent 61e657a2fb
commit d75e54f70c
  1. 392
      pkgs/applications/office/libreoffice/default.nix

@ -1,29 +1,125 @@
{ stdenv, fetchurl, lib, pam, python3, libxslt, perl, ArchiveZip, box2d, gettext { stdenv
, IOCompress, zlib, libjpeg, expat, freetype, libwpd , fetchurl
, libxml2, db, curl, fontconfig, libsndfile, neon , lib
, bison, flex, zip, unzip, gtk3, libmspack, getopt, file, cairo, which , pam
, icu, boost, jdk, ant, cups, xorg, fontforge, jre_minimal , python3
, openssl, gperf, cppunit, poppler, util-linux , libxslt
, librsvg, libGLU, libGL, bsh, CoinMP, libwps, libabw, libmysqlclient , perl
, autoconf, automake, openldap, bash, hunspell, librdf_redland, nss, nspr , ArchiveZip
, libwpg, dbus-glib, clucene_core, libcdr, lcms , box2d
, unixODBC, mdds, sane-backends, mythes, libexttextcat, libvisio , gettext
, fontsConf, pkg-config, bluez5, libtool, carlito , IOCompress
, libatomic_ops, graphite2, harfbuzz, libodfgen, libzmf , zlib
, librevenge, libe-book, libmwaw, glm, gst_all_1 , libjpeg
, gdb, commonsLogging, librdf_rasqal, wrapGAppsHook , expat
, gnome, glib, ncurses, libepoxy, gpgme, abseil-cpp , freetype
, libwpd
, libxml2
, db
, curl
, fontconfig
, libsndfile
, neon
, bison
, flex
, zip
, unzip
, gtk3
, libmspack
, getopt
, file
, cairo
, which
, icu
, boost
, jdk
, ant
, cups
, xorg
, fontforge
, jre_minimal
, openssl
, gperf
, cppunit
, poppler
, util-linux
, librsvg
, libGLU
, libGL
, bsh
, CoinMP
, libwps
, libabw
, libmysqlclient
, autoconf
, automake
, openldap
, bash
, hunspell
, librdf_redland
, nss
, nspr
, libwpg
, dbus-glib
, clucene_core
, libcdr
, lcms
, unixODBC
, mdds
, sane-backends
, mythes
, libexttextcat
, libvisio
, fontsConf
, pkg-config
, bluez5
, libtool
, carlito
, libatomic_ops
, graphite2
, harfbuzz
, libodfgen
, libzmf
, librevenge
, libe-book
, libmwaw
, glm
, gst_all_1
, gdb
, commonsLogging
, librdf_rasqal
, wrapGAppsHook
, gnome
, glib
, ncurses
, libepoxy
, gpgme
, abseil-cpp
, langs ? [ "ca" "cs" "da" "de" "en-GB" "en-US" "eo" "es" "fr" "hu" "it" "ja" "nl" "pl" "pt" "pt-BR" "ro" "ru" "sl" "uk" "zh-CN" ] , langs ? [ "ca" "cs" "da" "de" "en-GB" "en-US" "eo" "es" "fr" "hu" "it" "ja" "nl" "pl" "pt" "pt-BR" "ro" "ru" "sl" "uk" "zh-CN" ]
, withHelp ? true , withHelp ? true
, kdeIntegration ? false, mkDerivation ? null, qtbase ? null, qtx11extras ? null , kdeIntegration ? false
, ki18n ? null, kconfig ? null, kcoreaddons ? null, kio ? null, kwindowsystem ? null , mkDerivation ? null
, qtbase ? null
, qtx11extras ? null
, ki18n ? null
, kconfig ? null
, kcoreaddons ? null
, kio ? null
, kwindowsystem ? null
, wrapQtAppsHook ? null , wrapQtAppsHook ? null
, variant ? "fresh" , variant ? "fresh"
, symlinkJoin
} @ args: } @ args:
assert builtins.elem variant [ "fresh" "still" ]; assert builtins.elem variant [ "fresh" "still" ];
let let
inherit (lib)
flatten flip
concatMapStrings concatMapStringsSep concatStringsSep
getDev getLib
optional optionals optionalString;
jre' = jre_minimal.override { jre' = jre_minimal.override {
modules = [ "java.base" "java.desktop" "java.logging" ]; modules = [ "java.base" "java.desktop" "java.logging" ];
}; };
@ -34,27 +130,43 @@ let
inherit (primary-src) major minor subdir version; inherit (primary-src) major minor subdir version;
langsSpaces = lib.concatStringsSep " " langs; langsSpaces = concatStringsSep " " langs;
mkDrv = if kdeIntegration then mkDerivation else stdenv.mkDerivation; mkDrv = if kdeIntegration then mkDerivation else stdenv.mkDerivation;
srcs = { srcs = {
third_party = third_party =
map (x : ((fetchurl {inherit (x) url sha256 name;}) // {inherit (x) md5name md5;})) map (x: ((fetchurl { inherit (x) url sha256 name; }) // { inherit (x) md5name md5; }))
(importVariant "download.nix" ++ [ (importVariant "download.nix" ++ [
(rec { (rec {
name = "unowinreg.dll"; name = "unowinreg.dll";
url = "https://dev-www.libreoffice.org/extern/${md5name}"; url = "https://dev-www.libreoffice.org/extern/${md5name}";
sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga"; sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga";
md5 = "185d60944ea767075d27247c3162b3bc"; md5 = "185d60944ea767075d27247c3162b3bc";
md5name = "${md5}-${name}"; md5name = "${md5}-${name}";
}) })
]); ]);
translations = primary-src.translations; translations = primary-src.translations;
help = primary-src.help; help = primary-src.help;
}; };
in (mkDrv rec {
# See `postPatch` for details
kdeDeps = symlinkJoin {
name = "libreoffice-kde-dependencies-${version}";
paths = flatten (map (e: [ (getDev e) (getLib e) ]) [
qtbase
qtx11extras
kconfig
kcoreaddons
ki18n
kio
kwindowsystem
]);
};
in
(mkDrv rec {
pname = "libreoffice"; pname = "libreoffice";
inherit version; inherit version;
@ -71,10 +183,10 @@ in (mkDrv rec {
postUnpack = '' postUnpack = ''
mkdir -v $sourceRoot/${tarballPath} mkdir -v $sourceRoot/${tarballPath}
'' + (lib.flip lib.concatMapStrings srcs.third_party (f: '' '' + (flip concatMapStrings srcs.third_party (f: ''
ln -sfv ${f} $sourceRoot/${tarballPath}/${f.md5name} ln -sfv ${f} $sourceRoot/${tarballPath}/${f.md5name}
ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name} ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name}
'')) ''))
+ '' + ''
ln -sv ${srcs.help} $sourceRoot/${tarballPath}/${srcs.help.name} ln -sv ${srcs.help} $sourceRoot/${tarballPath}/${srcs.help.name}
ln -svf ${srcs.translations} $sourceRoot/${tarballPath}/${srcs.translations.name} ln -svf ${srcs.translations} $sourceRoot/${tarballPath}/${srcs.translations.name}
@ -97,16 +209,20 @@ in (mkDrv rec {
### QT/KDE ### QT/KDE
# #
# We have to resort to the ugly patching of configure.ac as it assumes that # configure.ac assumes that the first directory that contains headers and
# the first directory that contains headers and libraries during the check # libraries during its checks contains *all* the relevant headers/libs which
# contains all the relevant headers/libs which doesn't work with both as they # obviously doesn't work for us, so we have 2 options:
# are in multiple directories due to each having their own derivation. #
postPatch = let # 1. patch configure.ac in order to specify the direct paths to various Qt/KDE
inc = e: path: # dependencies which is ugly and brittle, or
"${lib.getDev e}/include/KF5/${path}"; #
libs = list: # 2. use symlinkJoin to pull in the relevant dependencies and just patch in
lib.concatMapStringsSep " " (e: "-L${lib.getLib e}/lib") list; # that path which is *also* ugly, but far less likely to break
in '' #
# The 2nd option is not very Nix'y, but I'll take robust over nice any day.
# Additionally, it's much easier to fix if LO breaks on the next upgrade (just
# add the missing dependencies to it).
postPatch = ''
substituteInPlace shell/source/unix/exec/shellexec.cxx \ substituteInPlace shell/source/unix/exec/shellexec.cxx \
--replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"} --replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"}
@ -119,21 +235,12 @@ in (mkDrv rec {
substituteInPlace configure.ac --replace \ substituteInPlace configure.ac --replace \
'GPGMEPP_CFLAGS=-I/usr/include/gpgme++' \ 'GPGMEPP_CFLAGS=-I/usr/include/gpgme++' \
'GPGMEPP_CFLAGS=-I${gpgme.dev}/include/gpgme++' 'GPGMEPP_CFLAGS=-I${gpgme.dev}/include/gpgme++'
'' + lib.optionalString kdeIntegration '' '' + optionalString kdeIntegration ''
substituteInPlace configure.ac \ substituteInPlace configure.ac \
--replace kcoreaddons_version.h KCoreAddons/kcoreaddons_version.h \ --replace '$QT5INC ' '$QT5INC ${kdeDeps}/include ' \
--replace '$QT5INC' ${qtbase.dev}/include \ --replace '$QT5LIB ' '$QT5LIB ${kdeDeps}/lib ' \
--replace '$QT5LIB' ${qtbase.out}/lib \ --replace '$KF5INC ' '$KF5INC ${kdeDeps}/include ${kdeDeps}/include/KF5 '\
--replace '-I$qt5_incdir ' '-I${qtx11extras.dev}/include '\ --replace '$KF5LIB ' '$KF5LIB ${kdeDeps}/lib '
--replace '-L$qt5_libdir ' '${libs [ qtbase qtx11extras ]} ' \
--replace '$KF5INC' ${kcoreaddons.dev}/include \
--replace '$KF5LIB' ${kcoreaddons.out}/lib \
--replace '$kf5_incdir/KCore' ${inc kcoreaddons "KCore"} \
--replace '$kf5_incdir/KI18n' ${inc ki18n "KI18n"} \
--replace '$kf5_incdir/KConfig' ${inc kconfig "KConfig"} \
--replace '$kf5_incdir/KWindow' ${inc kwindowsystem "KWindow"} \
--replace '$kf5_incdir/KIO' ${inc kio "KIO"} \
--replace '-L$kf5_libdir ' '${libs [ kconfig kcoreaddons ki18n kio kwindowsystem ]} '
''; '';
dontUseCmakeConfigure = true; dontUseCmakeConfigure = true;
@ -239,18 +346,16 @@ in (mkDrv rec {
'' ''
# This to avoid using /lib:/usr/lib at linking # This to avoid using /lib:/usr/lib at linking
+ '' + ''
sed -i '/gb_LinkTarget_LDFLAGS/{ n; /rpath-link/d;}' solenv/gbuild/platform/unxgcc.mk sed -i '/gb_LinkTarget_LDFLAGS/{ n; /rpath-link/d;}' solenv/gbuild/platform/unxgcc.mk
find -name "*.cmd" -exec sed -i s,/lib:/usr/lib,, {} \; find -name "*.cmd" -exec sed -i s,/lib:/usr/lib,, {} \;
''; '';
makeFlags = [ "SHELL=${bash}/bin/bash" ]; makeFlags = [ "SHELL=${bash}/bin/bash" ];
enableParallelBuilding = true; enableParallelBuilding = true;
buildPhase = '' buildTargets = [ "build-nocheck" ];
make build-nocheck
'';
doCheck = true; doCheck = true;
@ -278,19 +383,18 @@ in (mkDrv rec {
mkdir -p $dev mkdir -p $dev
cp -r include $dev cp -r include $dev
'' + lib.optionalString kdeIntegration '' '' + optionalString kdeIntegration ''
for prog in $out/bin/* for prog in $out/bin/*; do
do wrapQtApp $prog
wrapQtApp $prog done
done
''; '';
dontWrapQtApps = true; dontWrapQtApps = true;
configureFlags = [ configureFlags = [
(if withHelp then "" else "--without-help") (if withHelp then "" else "--without-help")
"--with-boost=${boost.dev}" "--with-boost=${getDev boost}"
"--with-boost-libdir=${boost.out}/lib" "--with-boost-libdir=${getLib boost}/lib"
"--with-beanshell-jar=${bsh}" "--with-beanshell-jar=${bsh}"
"--with-vendor=NixOS" "--with-vendor=NixOS"
"--disable-report-builder" "--disable-report-builder"
@ -299,7 +403,7 @@ in (mkDrv rec {
"--enable-dbus" "--enable-dbus"
"--enable-release-build" "--enable-release-build"
"--enable-epm" "--enable-epm"
"--with-ant-home=${ant}/lib/ant" "--with-ant-home=${getLib ant}/lib/ant"
"--with-system-cairo" "--with-system-cairo"
"--with-system-libs" "--with-system-libs"
"--with-system-headers" "--with-system-headers"
@ -347,44 +451,128 @@ in (mkDrv rec {
# https://github.com/NixOS/nixpkgs/commit/5c5362427a3fa9aefccfca9e531492a8735d4e6f # https://github.com/NixOS/nixpkgs/commit/5c5362427a3fa9aefccfca9e531492a8735d4e6f
"--without-system-orcus" "--without-system-orcus"
"--without-system-xmlsec" "--without-system-xmlsec"
] ++ lib.optionals kdeIntegration [ ] ++ optionals kdeIntegration [
"--enable-kf5" "--enable-kf5"
"--enable-qt5" "--enable-qt5"
"--enable-gtk3-kde5" "--enable-gtk3-kde5"
]; ];
checkPhase = '' checkTarget = concatStringsSep " " [
make unitcheck "unitcheck"
make slowcheck "slowcheck"
''; ];
nativeBuildInputs = [ nativeBuildInputs = [
gdb fontforge autoconf automake bison pkg-config libtool jdk autoconf
] ++ lib.optional (!kdeIntegration) wrapGAppsHook automake
++ lib.optional kdeIntegration wrapQtAppsHook; bison
fontforge
buildInputs = with xorg; gdb
[ ant ArchiveZip boost box2d cairo clucene_core jdk
IOCompress cppunit cups curl db dbus-glib expat file flex fontconfig libtool
freetype getopt gperf gtk3 pkg-config
hunspell icu jre' lcms libcdr libexttextcat unixODBC libjpeg ]
libmspack librdf_redland librsvg libsndfile libvisio libwpd libwpg libX11 ++ [ (if kdeIntegration then wrapQtAppsHook else wrapGAppsHook) ];
libXaw libXext libXi libXinerama libxml2 libxslt libXtst
libXdmcp libpthreadstubs libGLU libGL mythes buildInputs = with xorg; [
glib libmysqlclient ArchiveZip
neon nspr nss openldap openssl pam perl pkg-config poppler CoinMP
python3 sane-backends unzip which zip zlib IOCompress
mdds bluez5 libwps libabw libzmf abseil-cpp
libxshmfence libatomic_ops graphite2 harfbuzz gpgme util-linux ant
librevenge libe-book libmwaw glm ncurses libepoxy bluez5
libodfgen CoinMP librdf_rasqal gnome.adwaita-icon-theme gettext abseil-cpp boost
] box2d
++ (with gst_all_1; [ cairo
gstreamer clucene_core
gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly cppunit
gst-libav cups
]) curl
++ lib.optional kdeIntegration [ qtbase qtx11extras kcoreaddons kio ]; db
dbus-glib
expat
file
flex
fontconfig
freetype
getopt
gettext
glib
glm
gnome.adwaita-icon-theme
gperf
gpgme
graphite2
gtk3
harfbuzz
hunspell
icu
jre'
lcms
libGL
libGLU
libX11
libXaw
libXdmcp
libXext
libXi
libXinerama
libXtst
libabw
libatomic_ops
libcdr
libe-book
libepoxy
libexttextcat
libjpeg
libmspack
libmwaw
libmysqlclient
libodfgen
libpthreadstubs
librdf_rasqal
librdf_redland
librevenge
librsvg
libsndfile
libvisio
libwpd
libwpg
libwps
libxml2
libxshmfence
libxslt
libzmf
mdds
mythes
ncurses
neon
nspr
nss
openldap
openssl
pam
perl
pkg-config
poppler
python3
sane-backends
unixODBC
unzip
util-linux
which
zip
zlib
]
++ (with gst_all_1; [
gst-libav
gst-plugins-bad
gst-plugins-base
gst-plugins-good
gst-plugins-ugly
gstreamer
])
++ optionals kdeIntegration [ qtbase qtx11extras kcoreaddons kio ];
passthru = { passthru = {
inherit srcs; inherit srcs;

Loading…
Cancel
Save