libreoffice: fix -qt build

+289 -101
+289 -101
pkgs/applications/office/libreoffice/default.nix
··· 1 - { stdenv, fetchurl, lib, pam, python3, libxslt, perl, ArchiveZip, box2d, gettext 2 - , IOCompress, zlib, libjpeg, expat, freetype, libwpd 3 - , libxml2, db, curl, fontconfig, libsndfile, neon 4 - , bison, flex, zip, unzip, gtk3, libmspack, getopt, file, cairo, which 5 - , icu, boost, jdk, ant, cups, xorg, fontforge, jre_minimal 6 - , openssl, gperf, cppunit, poppler, util-linux 7 - , librsvg, libGLU, libGL, bsh, CoinMP, libwps, libabw, libmysqlclient 8 - , autoconf, automake, openldap, bash, hunspell, librdf_redland, nss, nspr 9 - , libwpg, dbus-glib, clucene_core, libcdr, lcms 10 - , unixODBC, mdds, sane-backends, mythes, libexttextcat, libvisio 11 - , fontsConf, pkg-config, bluez5, libtool, carlito 12 - , libatomic_ops, graphite2, harfbuzz, libodfgen, libzmf 13 - , librevenge, libe-book, libmwaw, glm, gst_all_1 14 - , gdb, commonsLogging, librdf_rasqal, wrapGAppsHook 15 - , gnome, glib, ncurses, libepoxy, gpgme, abseil-cpp 1 + { stdenv 2 + , fetchurl 3 + , lib 4 + , pam 5 + , python3 6 + , libxslt 7 + , perl 8 + , ArchiveZip 9 + , box2d 10 + , gettext 11 + , IOCompress 12 + , zlib 13 + , libjpeg 14 + , expat 15 + , freetype 16 + , libwpd 17 + , libxml2 18 + , db 19 + , curl 20 + , fontconfig 21 + , libsndfile 22 + , neon 23 + , bison 24 + , flex 25 + , zip 26 + , unzip 27 + , gtk3 28 + , libmspack 29 + , getopt 30 + , file 31 + , cairo 32 + , which 33 + , icu 34 + , boost 35 + , jdk 36 + , ant 37 + , cups 38 + , xorg 39 + , fontforge 40 + , jre_minimal 41 + , openssl 42 + , gperf 43 + , cppunit 44 + , poppler 45 + , util-linux 46 + , librsvg 47 + , libGLU 48 + , libGL 49 + , bsh 50 + , CoinMP 51 + , libwps 52 + , libabw 53 + , libmysqlclient 54 + , autoconf 55 + , automake 56 + , openldap 57 + , bash 58 + , hunspell 59 + , librdf_redland 60 + , nss 61 + , nspr 62 + , libwpg 63 + , dbus-glib 64 + , clucene_core 65 + , libcdr 66 + , lcms 67 + , unixODBC 68 + , mdds 69 + , sane-backends 70 + , mythes 71 + , libexttextcat 72 + , libvisio 73 + , fontsConf 74 + , pkg-config 75 + , bluez5 76 + , libtool 77 + , carlito 78 + , libatomic_ops 79 + , graphite2 80 + , harfbuzz 81 + , libodfgen 82 + , libzmf 83 + , librevenge 84 + , libe-book 85 + , libmwaw 86 + , glm 87 + , gst_all_1 88 + , gdb 89 + , commonsLogging 90 + , librdf_rasqal 91 + , wrapGAppsHook 92 + , gnome 93 + , glib 94 + , ncurses 95 + , libepoxy 96 + , gpgme 97 + , abseil-cpp 16 98 , 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" ] 17 99 , withHelp ? true 18 - , kdeIntegration ? false, mkDerivation ? null, qtbase ? null, qtx11extras ? null 19 - , ki18n ? null, kconfig ? null, kcoreaddons ? null, kio ? null, kwindowsystem ? null 100 + , kdeIntegration ? false 101 + , mkDerivation ? null 102 + , qtbase ? null 103 + , qtx11extras ? null 104 + , ki18n ? null 105 + , kconfig ? null 106 + , kcoreaddons ? null 107 + , kio ? null 108 + , kwindowsystem ? null 20 109 , wrapQtAppsHook ? null 21 110 , variant ? "fresh" 111 + , symlinkJoin 22 112 } @ args: 23 113 24 114 assert builtins.elem variant [ "fresh" "still" ]; 25 115 26 116 let 117 + inherit (lib) 118 + flatten flip 119 + concatMapStrings concatMapStringsSep concatStringsSep 120 + getDev getLib 121 + optional optionals optionalString; 122 + 27 123 jre' = jre_minimal.override { 28 124 modules = [ "java.base" "java.desktop" "java.logging" ]; 29 125 }; ··· 34 130 35 131 inherit (primary-src) major minor subdir version; 36 132 37 - langsSpaces = lib.concatStringsSep " " langs; 133 + langsSpaces = concatStringsSep " " langs; 38 134 39 135 mkDrv = if kdeIntegration then mkDerivation else stdenv.mkDerivation; 40 136 41 137 srcs = { 42 138 third_party = 43 - map (x : ((fetchurl {inherit (x) url sha256 name;}) // {inherit (x) md5name md5;})) 44 - (importVariant "download.nix" ++ [ 45 - (rec { 46 - name = "unowinreg.dll"; 47 - url = "https://dev-www.libreoffice.org/extern/${md5name}"; 48 - sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga"; 49 - md5 = "185d60944ea767075d27247c3162b3bc"; 50 - md5name = "${md5}-${name}"; 51 - }) 52 - ]); 139 + map (x: ((fetchurl { inherit (x) url sha256 name; }) // { inherit (x) md5name md5; })) 140 + (importVariant "download.nix" ++ [ 141 + (rec { 142 + name = "unowinreg.dll"; 143 + url = "https://dev-www.libreoffice.org/extern/${md5name}"; 144 + sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga"; 145 + md5 = "185d60944ea767075d27247c3162b3bc"; 146 + md5name = "${md5}-${name}"; 147 + }) 148 + ]); 53 149 54 150 translations = primary-src.translations; 55 151 help = primary-src.help; 56 152 }; 57 - in (mkDrv rec { 153 + 154 + # See `postPatch` for details 155 + kdeDeps = symlinkJoin { 156 + name = "libreoffice-kde-dependencies-${version}"; 157 + paths = flatten (map (e: [ (getDev e) (getLib e) ]) [ 158 + qtbase 159 + qtx11extras 160 + kconfig 161 + kcoreaddons 162 + ki18n 163 + kio 164 + kwindowsystem 165 + ]); 166 + }; 167 + 168 + in 169 + (mkDrv rec { 58 170 pname = "libreoffice"; 59 171 inherit version; 60 172 ··· 71 183 72 184 postUnpack = '' 73 185 mkdir -v $sourceRoot/${tarballPath} 74 - '' + (lib.flip lib.concatMapStrings srcs.third_party (f: '' 75 - ln -sfv ${f} $sourceRoot/${tarballPath}/${f.md5name} 76 - ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name} 77 - '')) 186 + '' + (flip concatMapStrings srcs.third_party (f: '' 187 + ln -sfv ${f} $sourceRoot/${tarballPath}/${f.md5name} 188 + ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name} 189 + '')) 78 190 + '' 79 191 ln -sv ${srcs.help} $sourceRoot/${tarballPath}/${srcs.help.name} 80 192 ln -svf ${srcs.translations} $sourceRoot/${tarballPath}/${srcs.translations.name} ··· 97 209 98 210 ### QT/KDE 99 211 # 100 - # We have to resort to the ugly patching of configure.ac as it assumes that 101 - # the first directory that contains headers and libraries during the check 102 - # contains all the relevant headers/libs which doesn't work with both as they 103 - # are in multiple directories due to each having their own derivation. 104 - postPatch = let 105 - inc = e: path: 106 - "${lib.getDev e}/include/KF5/${path}"; 107 - libs = list: 108 - lib.concatMapStringsSep " " (e: "-L${lib.getLib e}/lib") list; 109 - in '' 212 + # configure.ac assumes that the first directory that contains headers and 213 + # libraries during its checks contains *all* the relevant headers/libs which 214 + # obviously doesn't work for us, so we have 2 options: 215 + # 216 + # 1. patch configure.ac in order to specify the direct paths to various Qt/KDE 217 + # dependencies which is ugly and brittle, or 218 + # 219 + # 2. use symlinkJoin to pull in the relevant dependencies and just patch in 220 + # that path which is *also* ugly, but far less likely to break 221 + # 222 + # The 2nd option is not very Nix'y, but I'll take robust over nice any day. 223 + # Additionally, it's much easier to fix if LO breaks on the next upgrade (just 224 + # add the missing dependencies to it). 225 + postPatch = '' 110 226 substituteInPlace shell/source/unix/exec/shellexec.cxx \ 111 227 --replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"} 112 228 ··· 119 235 substituteInPlace configure.ac --replace \ 120 236 'GPGMEPP_CFLAGS=-I/usr/include/gpgme++' \ 121 237 'GPGMEPP_CFLAGS=-I${gpgme.dev}/include/gpgme++' 122 - '' + lib.optionalString kdeIntegration '' 123 - substituteInPlace configure.ac \ 124 - --replace kcoreaddons_version.h KCoreAddons/kcoreaddons_version.h \ 125 - --replace '$QT5INC' ${qtbase.dev}/include \ 126 - --replace '$QT5LIB' ${qtbase.out}/lib \ 127 - --replace '-I$qt5_incdir ' '-I${qtx11extras.dev}/include '\ 128 - --replace '-L$qt5_libdir ' '${libs [ qtbase qtx11extras ]} ' \ 129 - --replace '$KF5INC' ${kcoreaddons.dev}/include \ 130 - --replace '$KF5LIB' ${kcoreaddons.out}/lib \ 131 - --replace '$kf5_incdir/KCore' ${inc kcoreaddons "KCore"} \ 132 - --replace '$kf5_incdir/KI18n' ${inc ki18n "KI18n"} \ 133 - --replace '$kf5_incdir/KConfig' ${inc kconfig "KConfig"} \ 134 - --replace '$kf5_incdir/KWindow' ${inc kwindowsystem "KWindow"} \ 135 - --replace '$kf5_incdir/KIO' ${inc kio "KIO"} \ 136 - --replace '-L$kf5_libdir ' '${libs [ kconfig kcoreaddons ki18n kio kwindowsystem ]} ' 238 + '' + optionalString kdeIntegration '' 239 + substituteInPlace configure.ac \ 240 + --replace '$QT5INC ' '$QT5INC ${kdeDeps}/include ' \ 241 + --replace '$QT5LIB ' '$QT5LIB ${kdeDeps}/lib ' \ 242 + --replace '$KF5INC ' '$KF5INC ${kdeDeps}/include ${kdeDeps}/include/KF5 '\ 243 + --replace '$KF5LIB ' '$KF5LIB ${kdeDeps}/lib ' 137 244 ''; 138 245 139 246 dontUseCmakeConfigure = true; ··· 239 346 '' 240 347 # This to avoid using /lib:/usr/lib at linking 241 348 + '' 242 - sed -i '/gb_LinkTarget_LDFLAGS/{ n; /rpath-link/d;}' solenv/gbuild/platform/unxgcc.mk 349 + sed -i '/gb_LinkTarget_LDFLAGS/{ n; /rpath-link/d;}' solenv/gbuild/platform/unxgcc.mk 243 350 244 - find -name "*.cmd" -exec sed -i s,/lib:/usr/lib,, {} \; 351 + find -name "*.cmd" -exec sed -i s,/lib:/usr/lib,, {} \; 245 352 ''; 246 353 247 354 makeFlags = [ "SHELL=${bash}/bin/bash" ]; 248 355 249 356 enableParallelBuilding = true; 250 357 251 - buildPhase = '' 252 - make build-nocheck 253 - ''; 358 + buildTargets = [ "build-nocheck" ]; 254 359 255 360 doCheck = true; 256 361 ··· 278 383 279 384 mkdir -p $dev 280 385 cp -r include $dev 281 - '' + lib.optionalString kdeIntegration '' 282 - for prog in $out/bin/* 283 - do 284 - wrapQtApp $prog 285 - done 386 + '' + optionalString kdeIntegration '' 387 + for prog in $out/bin/*; do 388 + wrapQtApp $prog 389 + done 286 390 ''; 287 391 288 392 dontWrapQtApps = true; 289 393 290 394 configureFlags = [ 291 395 (if withHelp then "" else "--without-help") 292 - "--with-boost=${boost.dev}" 293 - "--with-boost-libdir=${boost.out}/lib" 396 + "--with-boost=${getDev boost}" 397 + "--with-boost-libdir=${getLib boost}/lib" 294 398 "--with-beanshell-jar=${bsh}" 295 399 "--with-vendor=NixOS" 296 400 "--disable-report-builder" ··· 299 403 "--enable-dbus" 300 404 "--enable-release-build" 301 405 "--enable-epm" 302 - "--with-ant-home=${ant}/lib/ant" 406 + "--with-ant-home=${getLib ant}/lib/ant" 303 407 "--with-system-cairo" 304 408 "--with-system-libs" 305 409 "--with-system-headers" ··· 347 451 # https://github.com/NixOS/nixpkgs/commit/5c5362427a3fa9aefccfca9e531492a8735d4e6f 348 452 "--without-system-orcus" 349 453 "--without-system-xmlsec" 350 - ] ++ lib.optionals kdeIntegration [ 454 + ] ++ optionals kdeIntegration [ 351 455 "--enable-kf5" 352 456 "--enable-qt5" 353 457 "--enable-gtk3-kde5" 354 458 ]; 355 459 356 - checkPhase = '' 357 - make unitcheck 358 - make slowcheck 359 - ''; 460 + checkTarget = concatStringsSep " " [ 461 + "unitcheck" 462 + "slowcheck" 463 + ]; 360 464 361 465 nativeBuildInputs = [ 362 - gdb fontforge autoconf automake bison pkg-config libtool jdk 363 - ] ++ lib.optional (!kdeIntegration) wrapGAppsHook 364 - ++ lib.optional kdeIntegration wrapQtAppsHook; 466 + autoconf 467 + automake 468 + bison 469 + fontforge 470 + gdb 471 + jdk 472 + libtool 473 + pkg-config 474 + ] 475 + ++ [ (if kdeIntegration then wrapQtAppsHook else wrapGAppsHook) ]; 365 476 366 - buildInputs = with xorg; 367 - [ ant ArchiveZip boost box2d cairo clucene_core 368 - IOCompress cppunit cups curl db dbus-glib expat file flex fontconfig 369 - freetype getopt gperf gtk3 370 - hunspell icu jre' lcms libcdr libexttextcat unixODBC libjpeg 371 - libmspack librdf_redland librsvg libsndfile libvisio libwpd libwpg libX11 372 - libXaw libXext libXi libXinerama libxml2 libxslt libXtst 373 - libXdmcp libpthreadstubs libGLU libGL mythes 374 - glib libmysqlclient 375 - neon nspr nss openldap openssl pam perl pkg-config poppler 376 - python3 sane-backends unzip which zip zlib 377 - mdds bluez5 libwps libabw libzmf 378 - libxshmfence libatomic_ops graphite2 harfbuzz gpgme util-linux 379 - librevenge libe-book libmwaw glm ncurses libepoxy 380 - libodfgen CoinMP librdf_rasqal gnome.adwaita-icon-theme gettext abseil-cpp 381 - ] 382 - ++ (with gst_all_1; [ 383 - gstreamer 384 - gst-plugins-base gst-plugins-good gst-plugins-bad gst-plugins-ugly 385 - gst-libav 386 - ]) 387 - ++ lib.optional kdeIntegration [ qtbase qtx11extras kcoreaddons kio ]; 477 + buildInputs = with xorg; [ 478 + ArchiveZip 479 + CoinMP 480 + IOCompress 481 + abseil-cpp 482 + ant 483 + bluez5 484 + boost 485 + box2d 486 + cairo 487 + clucene_core 488 + cppunit 489 + cups 490 + curl 491 + db 492 + dbus-glib 493 + expat 494 + file 495 + flex 496 + fontconfig 497 + freetype 498 + getopt 499 + gettext 500 + glib 501 + glm 502 + gnome.adwaita-icon-theme 503 + gperf 504 + gpgme 505 + graphite2 506 + gtk3 507 + harfbuzz 508 + hunspell 509 + icu 510 + jre' 511 + lcms 512 + libGL 513 + libGLU 514 + libX11 515 + libXaw 516 + libXdmcp 517 + libXext 518 + libXi 519 + libXinerama 520 + libXtst 521 + libabw 522 + libatomic_ops 523 + libcdr 524 + libe-book 525 + libepoxy 526 + libexttextcat 527 + libjpeg 528 + libmspack 529 + libmwaw 530 + libmysqlclient 531 + libodfgen 532 + libpthreadstubs 533 + librdf_rasqal 534 + librdf_redland 535 + librevenge 536 + librsvg 537 + libsndfile 538 + libvisio 539 + libwpd 540 + libwpg 541 + libwps 542 + libxml2 543 + libxshmfence 544 + libxslt 545 + libzmf 546 + mdds 547 + mythes 548 + ncurses 549 + neon 550 + nspr 551 + nss 552 + openldap 553 + openssl 554 + pam 555 + perl 556 + pkg-config 557 + poppler 558 + python3 559 + sane-backends 560 + unixODBC 561 + unzip 562 + util-linux 563 + which 564 + zip 565 + zlib 566 + ] 567 + ++ (with gst_all_1; [ 568 + gst-libav 569 + gst-plugins-bad 570 + gst-plugins-base 571 + gst-plugins-good 572 + gst-plugins-ugly 573 + gstreamer 574 + ]) 575 + ++ optionals kdeIntegration [ qtbase qtx11extras kcoreaddons kio ]; 388 576 389 577 passthru = { 390 578 inherit srcs;