102 , langs ? [ "ar" "ca" "cs" "da" "de" "en-GB" "en-US" "eo" "es" "fi" "fr" "hu" "it" "ja" "ko" "nl" "pl" "pt" "pt-BR" "ro" "ru" "sk" "sl" "tr" "uk" "zh-CN" "zh-TW" ]
105 , kdeIntegration ? false
113 , kwindowsystem ? null
124 , liberation-sans-narrow
129 , noto-fonts-cjk-sans
134 # The rest are used only in passthru, for the wrapper
137 , kconfigwidgets ? null
138 , kglobalaccel ? null
140 , knotifications ? null
141 , ktextwidgets ? null
142 , kwidgetsaddons ? null
145 , qtdeclarative ? null
146 , qtmultimedia ? null
147 , qtquickcontrols ? null
154 assert builtins.elem variant [ "fresh" "still" "collabora" ];
159 concatMapStrings concatStringsSep
161 optionals optionalString;
163 fontsConf = makeFontsConf {
171 liberation-sans-narrow
180 jre' = jre21_minimal.override {
181 modules = [ "java.base" "java.desktop" "java.logging" "java.sql" ];
184 importVariant = f: import (./. + "/src-${variant}/${f}");
185 # Update these files with:
186 # nix-shell maintainers/scripts/update.nix --argstr package libreoffice-$VARIANT.unwrapped
187 version = importVariant "version.nix";
189 main = importVariant "main.nix";
190 help = importVariant "help.nix";
191 translations = importVariant "translations.nix";
192 deps = (importVariant "deps.nix") ++ [
193 # TODO: Why is this needed?
195 name = "unowinreg.dll";
196 url = "https://dev-www.libreoffice.org/extern/${md5name}";
197 sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga";
198 md5 = "185d60944ea767075d27247c3162b3bc";
199 md5name = "${md5}-${name}";
204 third_party = map (x:
206 inherit (x) url sha256 name;
208 inherit (x) md5name md5;
209 }) srcsAttributes.deps;
210 translations = srcsAttributes.translations { inherit fetchurl fetchgit; };
211 help = srcsAttributes.help { inherit fetchurl fetchgit; };
214 qtMajor = lib.versions.major qtbase.version;
216 # See `postPatch` for details
217 kdeDeps = symlinkJoin {
218 name = "libreoffice-kde-dependencies-${version}";
219 paths = flatten (map (e: [ (getDev e) (getLib e) ]) [
230 tarballPath = "external/tarballs";
232 in stdenv.mkDerivation (finalAttrs: {
233 pname = "libreoffice";
236 src = srcsAttributes.main { inherit fetchurl fetchgit; };
239 mkdir -v $sourceRoot/${tarballPath}
241 ${flip concatMapStrings srcs.third_party (f: ''
242 ln -sfv ${f} $sourceRoot/${tarballPath}/${f.md5name}
243 ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name}
246 '' + (if (variant != "collabora") then ''
247 ln -sv ${srcs.help} $sourceRoot/${tarballPath}/${srcs.help.name}
248 ln -svf ${srcs.translations} $sourceRoot/${tarballPath}/${srcs.translations.name}
251 tar -xf ${srcs.translations}
253 cp -r --no-preserve=mode ${srcs.help}/. $sourceRoot/helpcontent2/
254 cp -r --no-preserve=mode ${srcs.translations}/. $sourceRoot/translations/
258 # Skip some broken tests:
259 # - tdf160386 does not fall back to a CJK font properly for some reason
260 # - the remaining tests have notes in the patches
261 # FIXME: get rid of this ASAP
262 ./skip-broken-tests.patch
263 (./skip-broken-tests- + variant + ".patch")
265 # Don't detect Qt paths from qmake, so our patched-in onese are used
266 ./dont-detect-qt-paths-from-qmake.patch
268 # Revert part of https://github.com/LibreOffice/core/commit/6f60670877208612b5ea320b3677480ef6508abb that broke zlib linking
269 ./readd-explicit-zlib-link.patch
270 ] ++ lib.optionals (lib.versionOlder version "24.8") [
272 name = "icu74-compat.patch";
273 url = "https://gitlab.archlinux.org/archlinux/packaging/packages/libreoffice-fresh/-/raw/main/libreoffice-7.5.8.2-icu-74-compatibility.patch?ref_type=heads.patch";
274 hash = "sha256-OGBPIVQj8JTYlkKywt4QpH7ULAzKmet5jTLztGpIS0Y=";
276 ] ++ lib.optionals (variant == "collabora") [
277 ./fix-unpack-collabora.patch
281 # configure checks for header 'gpgme++/gpgmepp_version.h',
282 # and if it is found (no matter where) uses a hardcoded path
283 # in what presumably is an effort to make it possible to write
284 # '#include <context.h>' instead of '#include <gpgmepp/context.h>'.
286 # Fix this path to point to where the headers can actually be found instead.
287 substituteInPlace configure.ac --replace-fail \
288 'GPGMEPP_CFLAGS=-I/usr/include/gpgme++' \
289 'GPGMEPP_CFLAGS=-I${gpgme.dev}/include/gpgme++'
291 # Fix for Python 3.12
292 substituteInPlace configure.ac --replace-fail distutils.sysconfig sysconfig
295 nativeBuildInputs = [
306 buildInputs = finalAttrs.passthru.gst_packages ++ [
307 # Make libpng not handle APNG images, so LibreOffice's own handler kicks in
308 # This should be ordered first, so it gets picked up before any other
310 # See: https://www.mail-archive.com/libreoffice@lists.freedesktop.org/msg334080.html
311 (libpng.override { apngSupport = false; })
312 perlPackages.ArchiveZip
314 perlPackages.IOCompress
341 (harfbuzz.override { withIcu = true; })
408 ] ++ optionals kdeIntegration [
416 configureFlagsArray=(
417 "--with-parallelism=$NIX_BUILD_CORES"
418 # here because we need to be very specific about spaces
419 "--with-lang=${concatStringsSep " " langs}"
424 NOCONFIGURE=1 ./autogen.sh
425 '' + optionalString kdeIntegration ''
426 # configure.ac assumes that the first directory that contains headers and
427 # libraries during its checks contains *all* the relevant headers/libs which
428 # obviously doesn't work for us, so we have 2 options:
430 # 1. patch configure.ac in order to specify the direct paths to various Qt/KDE
431 # dependencies which is ugly and brittle, or
433 # 2. use symlinkJoin to pull in the relevant dependencies and just patch in
434 # that path which is *also* ugly, but far less likely to break
436 # The 2nd option is not very Nix'y, but I'll take robust over nice any day.
437 # Additionally, it's much easier to fix if LO breaks on the next upgrade (just
438 # add the missing dependencies to it).
439 export QT${qtMajor}INC=${kdeDeps}/include
440 export QT${qtMajor}LIB=${kdeDeps}/lib
441 export KF${qtMajor}INC="${kdeDeps}/include ${kdeDeps}/include/KF${qtMajor}"
442 export KF${qtMajor}LIB=${kdeDeps}/lib
446 # Explicitly passing in --host even on non-cross, because
447 # LibreOffice will attempt to detect WSL and cross-compile
448 # itself to Windows automatically, and we don't want it
450 "--host=${stdenv.hostPlatform.config}"
451 "--without-buildconfig-recorded"
453 (lib.withFeature withHelp "help")
454 "--with-boost=${getDev boost}"
455 "--with-boost-libdir=${getLib boost}/lib"
456 "--with-beanshell-jar=${bsh}"
457 "--with-vendor=NixOS"
458 "--disable-report-builder"
459 "--disable-online-update"
460 "--enable-python=system"
462 "--enable-release-build"
464 "--with-ant-home=${getLib ant}/lib/ant"
466 # Without these, configure does not finish
469 # Schema files for validation are not included in the source tarball
470 "--without-export-validation"
472 # We do tarball prefetching ourselves
473 "--disable-fetch-external"
474 "--enable-build-opensymbol"
476 # I imagine this helps. Copied from go-oo.
477 # Modified on every upgrade, though
479 "--disable-firebird-sdbc"
480 (lib.withFeature withFonts "fonts")
483 "--with-system-beanshell"
484 "--with-system-cairo"
485 "--with-system-coinmp"
486 "--with-system-headers"
487 "--with-system-libabw"
488 "--with-system-libcmis"
489 "--with-system-libepubgen"
490 "--with-system-libetonyek"
491 "--with-system-liblangtag"
493 "--with-system-libwps"
494 "--with-system-lpsolve"
496 "--with-system-openldap"
497 "--with-system-openssl"
498 "--with-system-orcus"
499 "--with-system-postgresql"
500 "--with-system-xmlsec"
502 # TODO: package these as system libraries
503 "--without-system-altlinuxhyph"
504 "--without-system-frozen"
505 "--without-system-libfreehand"
506 "--without-system-libmspub"
507 "--without-system-libnumbertext"
508 "--without-system-libpagemaker"
509 "--without-system-libstaroffice"
510 "--without-system-libqxp"
511 "--without-system-dragonbox"
512 "--without-system-libfixmath"
514 # requires an oddly specific, old version
515 "--without-system-hsqldb"
517 # searches hardcoded paths that are wrong
518 "--without-system-zxing"
520 # is packaged but headers can't be found because there is no pkg-config file
521 "--without-system-zxcvbn"
522 ] ++ optionals kdeIntegration [
523 "--enable-kf${qtMajor}"
524 "--enable-qt${qtMajor}"
525 ] ++ optionals (kdeIntegration && qtMajor == "5") [
527 ] ++ (if variant == "fresh" then [
528 "--with-system-rhino"
529 "--with-rhino-jar=${rhino}/share/java/js.jar"
531 # our Rhino is too new for older versions
532 "--without-system-rhino"
537 # FIXME: this is a hack, because the right cflags are not being picked up
538 # from rasqal's .pc file. Needs more investigation.
539 NIX_CFLAGS_COMPILE = "-I${librdf_rasqal}/include/rasqal";
541 # Provide all the fonts used in tests.
542 FONTCONFIG_FILE = fontsConf;
545 makeFlags = [ "SHELL=${bash}/bin/bash" ];
547 enableParallelBuilding = true;
549 buildTargets = [ "build-nocheck" ];
551 # Disable tests for the Qt5 build, as they seem even more flaky
552 # than usual, and we will drop the Qt5 build after 24.11 anyway.
553 doCheck = !(kdeIntegration && qtMajor == "5");
559 checkTarget = concatStringsSep " " [
562 "--keep-going" # easier to debug test failures
565 postInstall = optionalString (variant != "collabora") ''
566 mkdir -p $out/{include,share/icons}
568 cp -r include/LibreOfficeKit $out/include/
569 cp -r sysui/desktop/icons/hicolor $out/share/icons
571 # Rename icons for consistency
572 for file in $out/share/icons/hicolor/*/apps/*; do
573 mv $file "$(dirname $file)/libreoffice-$(basename $file)"
576 ln -s $out/lib/libreoffice/share/xdg $out/share/applications
578 # Unversionize desktop files
579 . ./bin/get_config_variables PRODUCTVERSION
580 for file in $out/lib/libreoffice/share/xdg/*.desktop; do
581 substituteInPlace $file \
582 --replace-fail "LibreOffice $PRODUCTVERSION" "LibreOffice" \
583 --replace-warn "Icon=libreoffice$PRODUCTVERSION" "Icon=libreoffice" \
584 --replace-fail "Exec=libreoffice$PRODUCTVERSION" "Exec=libreoffice"
588 # Wrapping is done in ./wrapper.nix
589 dontWrapQtApps = true;
594 python = python311; # for unoconv
597 # Pass it this file name as argument
598 (builtins.unsafeGetAttrPos "pname" finalAttrs.finalPackage).file
602 inherit kdeIntegration;
603 # For the wrapper.nix
605 # Although present in qtPackages, we need qtbase.qtPluginPrefix and
608 gst_packages = with gst_all_1; [
649 # libreoffice tries to reference the BUILDCONFIG (e.g. PKG_CONFIG_PATH)
650 # in the binary causing the closure size to blow up because of many unnecessary
651 # dependencies to dev outputs. This behavior was patched away in nixpkgs
652 # (see above), make sure these don't leak again by accident.
653 # FIXME: disabled for kdeIntegration builds because the weird symlinkJoin setup
654 # leaks all the -dev dependencies :(
655 disallowedRequisites = lib.optionals (!kdeIntegration) (lib.concatMap (x: lib.optional (x?dev) x.dev) finalAttrs.buildInputs);
657 requiredSystemFeatures = [ "big-parallel" ];
660 changelog = "https://wiki.documentfoundation.org/ReleaseNotes/${lib.versions.majorMinor version}";
661 description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org";
662 homepage = "https://libreoffice.org/";
663 # at least one jar in dependencies
664 sourceProvenance = with sourceTypes; [ binaryBytecode ];
665 license = licenses.lgpl3;
666 maintainers = with maintainers; [ raskin ];
667 platforms = platforms.linux;
668 mainProgram = "libreoffice";