Building LibreOffice master

I’m trying to modify the nixpkg for LibreOffice, so I could build master. I have modified the files, so they point to my local clone of the source.

I have received some advice and am using this build command at the moment:
nix-build --argstr variant master -E 'with import <nixpkgs> {}; callPackage ./default.nix { ArchiveZip = perlPackages.ArchiveZip; IOCompress = perlPackages.IOCompress;}'

Currently I am facing this error:
attempt to call something which is not a function but null, at /home/user/libreoffice-nix/default.nix:57:5
referring to the line
in (mkDrv rec {
in the default.nix.

My own modified default.nix starts like this:

with import <nixpkgs> {};
{ stdenv, fetchurl, fetchpatch, lib, pam, python3, libxslt, perl, ArchiveZip, gettext
, IOCompress, zlib, libjpeg, expat, freetype, libwpd
, libxml2, db, curl, fontconfig, libsndfile, neon
, bison, flex, zip, unzip, gtk3, libmspack, getopt, file, cairo, which
, icu, boost, jdk, ant, cups, xorg, libcmis, fontforge
, openssl, gperf, cppunit, poppler, utillinux
, librsvg, libGLU, libGL, bsh, CoinMP, libwps, libabw, libmysqlclient
, autoconf, automake, openldap, bash, hunspell, librdf_redland, nss, nspr
, libwpg, dbus-glib, clucene_core, libcdr, lcms, vigra
, unixODBC, mdds, sane-backends, mythes, libexttextcat, libvisio
, pkgconfig, bluez5, libtool, carlito
, libatomic_ops, graphite2, harfbuzz, libodfgen, libzmf
, librevenge, libe-book, libmwaw, glm, glew, gst_all_1
, gdb, commonsLogging, librdf_rasqal, wrapGAppsHook
, gnome3, glib, ncurses, epoxy, gpgme
, langs ? [ "en-US" ]
, withHelp ? false
, kdeIntegration ? true, mkDerivation ? null, qtbase ? null, qtx11extras ? null
, ki18n ? null, kconfig ? null, kcoreaddons ? null, kio ? null, kwindowsystem ? null
, variant ? "master"
} @ args:

assert builtins.elem variant [ "master" ];

let
  fontsConf = makeFontsConf {
    fontDirectories = [ ];
  };

What should I do to have mkDerivation be something other than null (I don’t know what it is supposed to be)?

What should I do to have mkDerivation be something other than null (I don’t know what it is supposed to be)?

Look into all-packages.nix; either you need to use kdeIntegration and Qt version of callPackage, or normal callPackage and no KDE integration.

1 Like

Thanks a lot, managed to get past the previous problem by calling nix-build with libsForQt5.callPackage

I did some more editing and things progressed up to the point, where I need to figure out how to make it deal with my cloned sources instead of the source archives:

unpacking source archive /home/user/libreoffice
do not know how to unpack source archive /home/user/libreoffice

My src-master/primary.nix is now simply

rec {
  src = "/home/user/libreoffice";
  translations = "/home/user/libreoffice/translations";
  help = "/home/user/libreoffice/help";
}

While my default.nix has been trimmed down to

with import <nixpkgs> {};
{ stdenv, fetchurl, fetchpatch, lib, pam, python3, libxslt, perl, ArchiveZip, gettext
, IOCompress, zlib, libjpeg, expat, freetype, libwpd
, libxml2, db, curl, fontconfig, libsndfile, neon
, bison, flex, zip, unzip, gtk3, libmspack, getopt, file, cairo, which
, icu, boost, jdk, ant, cups, xorg, libcmis, fontforge
, openssl, gperf, cppunit, poppler, utillinux
, 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
, pkgconfig, bluez5, libtool, carlito
, libatomic_ops, graphite2, harfbuzz, libodfgen, libzmf
, librevenge, libe-book, libmwaw, glm, gst_all_1
, gdb, commonsLogging, librdf_rasqal, wrapGAppsHook
, gnome3, glib, ncurses, epoxy, gpgme
, langs ? [ "en-US" ]
, withHelp ? false
, kdeIntegration ? true, mkDerivation ? null, qtbase ? null, qtx11extras ? null
, ki18n ? null, kconfig ? null, kcoreaddons ? null, kio ? null, kwindowsystem ? null
, variant ? "master"
} @ args:

assert builtins.elem variant [ "master" ];

let
  fontsConf = makeFontsConf {
    fontDirectories = [ ];
  };
  importVariant = f: import (./. + "/src-${variant}/${f}");

  primary-src = importVariant "primary.nix";

  langsSpaces = lib.concatStringsSep " " langs;

  mkDrv = if kdeIntegration then mkDerivation else stdenv.mkDerivation;

  srcs = {
    third_party =
      map (x : ((fetchurl {inherit (x) url sha256 name;}) // {inherit (x) md5name md5;}))
      (importVariant "download.nix" ++ [
        (rec {
          name = "unowinreg.dll";
          url = "https://dev-www.libreoffice.org/extern/${md5name}";
          sha256 = "1infwvv1p6i21scywrldsxs22f62x85mns4iq8h6vr6vlx3fdzga";
          md5 = "185d60944ea767075d27247c3162b3bc";
          md5name = "${md5}-${name}";
        })
      ]);

    translations = primary-src.translations;
    help = primary-src.help;
  };
in (mkDrv rec {
  name= "libreoffice-master";
  pname = "libreoffice-master";

  inherit (primary-src) src;

  outputs = [ "out" "dev" ];

  # For some reason librdf_redland sometimes refers to rasqal.h instead
  # of rasqal/rasqal.h
  NIX_CFLAGS_COMPILE = [
    "-I${librdf_rasqal}/include/rasqal"
  ] ++ lib.optionals stdenv.isx86_64 [ "-mno-fma" "-mno-avx" ]
  # https://bugs.documentfoundation.org/show_bug.cgi?id=78174#c10
  ++ [ "-fno-visibility-inlines-hidden" ];

  patches = [
    ./xdg-open-brief.patch
  ];

  tarballPath = "external/tarballs";

  postUnpack = ''
    mkdir -v $sourceRoot/${tarballPath}
  '' + (lib.flip lib.concatMapStrings srcs.third_party (f: ''
      ln -sfv ${f} $sourceRoot/${tarballPath}/${f.md5name}
      ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name}
    ''));

  ### QT/KDE
  #
  # We have to resort to the ugly patching of configure.ac as it assumes that
  # the first directory that contains headers and libraries during the check
  # contains all the relevant headers/libs which doesn't work with both as they
  # are in multiple directories due to each having their own derivation.
  postPatch = let
    inc = e: path:
      "${lib.getDev e}/include/KF5/${path}";
    libs = list:
      lib.concatMapStringsSep " " (e: "-L${lib.getLib e}/lib") list;
  in ''
    substituteInPlace shell/source/unix/exec/shellexec.cxx \
      --replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"}

    # configure checks for header 'gpgme++/gpgmepp_version.h',
    # and if it is found (no matter where) uses a hardcoded path
    # in what presumably is an effort to make it possible to write
    # '#include <context.h>' instead of '#include <gpgmepp/context.h>'.
    #
    # Fix this path to point to where the headers can actually be found instead.
    substituteInPlace configure.ac --replace \
      'GPGMEPP_CFLAGS=-I/usr/include/gpgme++' \
      'GPGMEPP_CFLAGS=-I${gpgme.dev}/include/gpgme++'
  '' + lib.optionalString kdeIntegration ''
      substituteInPlace configure.ac \
        --replace '$QT5INC'             ${qtbase.dev}/include \
        --replace '$QT5LIB'             ${qtbase.out}/lib \
        --replace '-I$qt5_incdir '      '-I${qtx11extras.dev}/include '\
        --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;
  dontUseCmakeBuildDir = true;

  preConfigure = ''
    configureFlagsArray=(
      "--with-parallelism=$NIX_BUILD_CORES"
      "--with-lang=${langsSpaces}"
    );

    chmod a+x ./bin/unpack-sources
    patchShebangs .

    # This is required as some cppunittests require fontconfig configured
    cp "${fontsConf}" fonts.conf
    sed -e '/include/i<include>${carlito}/etc/fonts/conf.d</include>' -i fonts.conf
    export FONTCONFIG_FILE="$PWD/fonts.conf"

    NOCONFIGURE=1 ./autogen.sh
  '';

  postConfigure =
    # Test fixups
    # May need to be revisited/pruned, left alone for now.
    ''
      # unit test sd_tiledrendering seems to be fragile
      # https://nabble.documentfoundation.org/libreoffice-5-0-failure-in-CUT-libreofficekit-tiledrendering-td4150319.html
      echo > ./sd/CppunitTest_sd_tiledrendering.mk
      sed -e /CppunitTest_sd_tiledrendering/d -i sd/Module_sd.mk
      # Pivot chart tests. Fragile.
      sed -e '/CPPUNIT_TEST(testRoundtrip)/d' -i chart2/qa/extras/PivotChartTest.cxx
      sed -e '/CPPUNIT_TEST(testPivotTableMedianODS)/d' -i sc/qa/unit/pivottable_filters_test.cxx
      # one more fragile test?
      sed -e '/CPPUNIT_TEST(testTdf96536);/d' -i sw/qa/extras/uiwriter/uiwriter.cxx
      # this I actually hate, this should be a data consistency test!
      sed -e '/CPPUNIT_TEST(testTdf115013);/d' -i sw/qa/extras/uiwriter/uiwriter.cxx
      # rendering-dependent test
      sed -e '/CPPUNIT_ASSERT_EQUAL(11148L, pOleObj->GetLogicRect().getWidth());/d ' -i sc/qa/unit/subsequent_filters-test.cxx
      # tilde expansion in path processing checks the existence of $HOME
      sed -e 's@OString sSysPath("~/tmp");@& return ; @' -i sal/qa/osl/file/osl_File.cxx
      # fails on systems using ZFS, see https://github.com/NixOS/nixpkgs/issues/19071
      sed -e '/CPPUNIT_TEST(getSystemPathFromFileURL_005);/d' -i './sal/qa/osl/file/osl_File.cxx'
      # rendering-dependent: on my computer the test table actually doesn't fit…
      # interesting fact: test disabled on macOS by upstream
      sed -re '/DECLARE_WW8EXPORT_TEST[(]testTableKeep, "tdf91083.odt"[)]/,+5d' -i ./sw/qa/extras/ww8export/ww8export.cxx
      # Segfault on DB access — maybe temporarily acceptable for a new version of Fresh?
      sed -e 's/CppunitTest_dbaccess_empty_stdlib_save//' -i ./dbaccess/Module_dbaccess.mk
      # one more fragile test?
      sed -e '/CPPUNIT_TEST(testTdf77014);/d' -i sw/qa/extras/uiwriter/uiwriter.cxx
      # rendering-dependent tests
      sed -e '/CPPUNIT_TEST(testCustomColumnWidthExportXLSX)/d' -i sc/qa/unit/subsequent_export-test.cxx
      sed -e '/CPPUNIT_TEST(testColumnWidthExportFromODStoXLSX)/d' -i sc/qa/unit/subsequent_export-test.cxx
      sed -e '/CPPUNIT_TEST(testChartImportXLS)/d' -i sc/qa/unit/subsequent_filters-test.cxx
      sed -e '/CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape)/d' -i sc/qa/unit/filters-test.cxx
      sed -zre 's/DesktopLOKTest::testGetFontSubset[^{]*[{]/& return; /' -i desktop/qa/desktop_lib/test_desktop_lib.cxx
      sed -z -r -e 's/DECLARE_OOXMLEXPORT_TEST[(]testFlipAndRotateCustomShape,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
      sed -z -r -e 's/DECLARE_OOXMLEXPORT_TEST[(]tdf105490_negativeMargins,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
      sed -z -r -e 's/DECLARE_OOXMLIMPORT_TEST[(]testTdf112443,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlimport/ooxmlimport.cxx
      sed -z -r -e 's/DECLARE_RTFIMPORT_TEST[(]testTdf108947,[^)]*[)].[{]/& return;/' -i sw/qa/extras/rtfimport/rtfimport.cxx
      # not sure about this fragile test
      sed -z -r -e 's/DECLARE_OOXMLEXPORT_TEST[(]testTDF87348,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
      # bunch of new Fresh failures. Sigh.
      sed -e '/CPPUNIT_TEST(testDocumentLayout);/d' -i './sd/qa/unit/import-tests.cxx'
      sed -e '/CPPUNIT_TEST(testErrorBarDataRangeODS);/d' -i './chart2/qa/extras/chart2export.cxx'
      sed -e '/CPPUNIT_TEST(testLabelStringODS);/d' -i './chart2/qa/extras/chart2export.cxx'
      sed -e '/CPPUNIT_TEST(testAxisNumberFormatODS);/d' -i './chart2/qa/extras/chart2export.cxx'
      sed -e '/CPPUNIT_TEST(testBackgroundImage);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testFdo84043);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf97630);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf80020);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf62176);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTransparentBackground);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedPdf);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedText);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf98477);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testAuthorField);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf50499);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf100926);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testPageWithTransparentBackground);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTextRotation);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf113818);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf119629);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf113822);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(test);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testConditionalFormatExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF16LErtlSHA1);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF8SHA1);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF8SHA256ODF12);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF8SHA256W3C);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_XL_SHA1);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testColorScaleExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testDataBarExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testNamedRangeBugfdo62729);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testRichTextExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testFormulaRefSheetNameODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCellValuesExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCellNoteExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testFormatExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedChartODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCellAnchoredGroupXLS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCeilingFloorODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testRelativePathsODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testSheetProtectionODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testSwappedOutImageExport);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testLinkedGraphicRT);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testImageWithSpecialID);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testAbsNamedRangeHTML);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testMoveCellAnchoredShapesODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testRefStringUnspecified);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testHeaderImageODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testTdf88657ODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testExponentWithoutSignFormatXLSX);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testHiddenRepeatedRowsODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testHyperlinkTargetFrameODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testTdf105739);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testPageBitmapWithTransparency);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf115005);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf115005_FallBack_Images_On);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf115005_FallBack_Images_Off);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf44774);/d' -i './sd/qa/unit/misc-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf38225);/d' -i './sd/qa/unit/misc-tests.cxx'
      sed -e '/CPPUNIT_TEST(testAuthorField);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testAuthorField);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testFdo85554);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedDataSource);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e '/CPPUNIT_TEST(testTdf96479);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e '/CPPUNIT_TEST(testInconsistentBookmark);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/ooxmlexport/ooxmlexport9.cxx"
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/ooxmlexport/ooxmlencryption.cxx"
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/odfexport/odfexport.cxx"
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/unowriter/unowriter.cxx"
    ''
    # This to avoid using /lib:/usr/lib at linking
    + ''
    sed -i '/gb_LinkTarget_LDFLAGS/{ n; /rpath-link/d;}' solenv/gbuild/platform/unxgcc.mk

    find -name "*.cmd" -exec sed -i s,/lib:/usr/lib,, {} \;
    '';

  makeFlags = [ "SHELL=${bash}/bin/bash" ];

  enableParallelBuilding = true;

  buildPhase = ''
    make
  '';

  doCheck = false;

  configureFlags = [
    (if withHelp then "" else "--without-help")
    "--with-boost=${boost.dev}"
    "--with-boost-libdir=${boost.out}/lib"
    "--with-beanshell-jar=${bsh}"
    "--with-vendor=NixOS"
    "--with-commons-logging-jar=${commonsLogging}/share/java/commons-logging-1.2.jar"
    "--disable-report-builder"
    "--disable-online-update"
    "--enable-python=system"
    "--enable-dbus"
    "--enable-release-build"
    "--enable-epm"
    "--with-jdk-home=${jdk.home}"
    "--with-ant-home=${ant}/lib/ant"
    "--with-system-cairo"
    "--with-system-libs"
    "--with-system-headers"
    "--with-system-openssl"
    "--with-system-libabw"
    "--with-system-libcmis"
    "--with-system-libwps"
    "--with-system-openldap"
    "--with-system-coinmp"

    # Without these, configure does not finish
    "--without-junit"

    # Schema files for validation are not included in the source tarball
    "--without-export-validation"

    "--disable-libnumbertext" # system-libnumbertext"

    # We do tarball prefetching ourselves
    "--disable-fetch-external"
    "--enable-build-opensymbol"

    # I imagine this helps. Copied from go-oo.
    # Modified on every upgrade, though
    "--disable-odk"
    "--disable-postgresql-sdbc"
    "--disable-firebird-sdbc"
    "--without-fonts"
    "--without-myspell-dicts"
    "--without-doxygen"

    # TODO: package these as system libraries
    "--with-system-beanshell"
    "--without-system-hsqldb"
    "--without-system-altlinuxhyph"
    "--without-system-lpsolve"
    "--without-system-libetonyek"
    "--without-system-libfreehand"
    "--without-system-liblangtag"
    "--without-system-libmspub"
    "--without-system-libpagemaker"
    "--without-system-libstaroffice"
    "--without-system-libepubgen"
    "--without-system-libqxp"
    "--without-system-mdds" # we have mdds but our version is too new
    # https://github.com/NixOS/nixpkgs/commit/5c5362427a3fa9aefccfca9e531492a8735d4e6f
    "--without-system-orcus"
    "--without-system-qrcodegen"
    "--without-system-xmlsec"
  ] ++ lib.optionals kdeIntegration [
    "--enable-kf5"
    "--enable-qt5"
  ];

  checkPhase = ''
    make unitcheck
    make slowcheck
  '';

  nativeBuildInputs = [
    gdb fontforge autoconf automake bison pkgconfig libtool
  ] ++ lib.optional (!kdeIntegration) wrapGAppsHook;

  buildInputs = with xorg;
    [ ant perlPackages.ArchiveZip boost cairo clucene_core
      perlPackages.IOCompress cppunit cups curl db dbus-glib expat file flex fontconfig
      freetype getopt gperf gtk3
      hunspell icu jdk lcms libcdr libexttextcat unixODBC libjpeg
      libmspack librdf_redland librsvg libsndfile libvisio libwpd libwpg libX11
      libXaw libXext libXi libXinerama libxml2 libxslt libXtst
      libXdmcp libpthreadstubs libGLU libGL mythes
      glib libmysqlclient
      neon nspr nss openldap openssl pam perl pkgconfig poppler
      python3 sane-backends unzip which zip zlib
      mdds bluez5 libcmis libwps libabw libzmf
      libxshmfence libatomic_ops graphite2 harfbuzz gpgme utillinux
      librevenge libe-book libmwaw glm ncurses epoxy
      libodfgen CoinMP librdf_rasqal gnome3.adwaita-icon-theme gettext
    ]
    ++ (with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good ])
    ++ lib.optional kdeIntegration [ qtbase qtx11extras kcoreaddons kio ];

  passthru = {
    inherit srcs jdk;
  };

  requiredSystemFeatures = [ "big-parallel" ];

  meta = with lib; {
    description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org";
    homepage = "https://libreoffice.org/";
    license = licenses.lgpl3;
    maintainers = with maintainers; [ raskin ];
    platforms = platforms.linux;
  };
}).overrideAttrs ((importVariant "override.nix") (args // { inherit kdeIntegration; }))

src = “/home/user/libreoffice”;

Well, builds are sandboxed and cannot see your home directory.

You can drop the quotes and let the evaluation step re-scan the directory every time and copy it to store. Or you could prepare a tarball, nix-prefetch-url it via file:// URL and put the store path into expression. Or you could fetchgit or fetchzip the snapshot (and as long as you specify the same hash it will be reused)

Cool. Dropping the quotes worked.

Now it fails with

checking which clucene to use… external
checking for libclucene-core… no
configure: error: Package requirements (libclucene-core) were not met:

No package ‘libclucene-core’ found

Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.

Alternatively, you may set the environment variables CLUCENE_CFLAGS
and CLUCENE_LIBS to avoid the need to call pkg-config.

This happens even if I use the autogen option --with-system-clucene

No package ‘libclucene-core’ found

I again recommend you to read how all-packages.nix calls LibreOffice expression, because it explicitly passes clucene_core_2 package to the clucene_core argument

1 Like

Oof, sorry, I was unable to find the file you referenced, apparently beause GitHub’s search is poop. Now I found it and it was not searchable without viewing the raw version. I will look into it, cheers.

The end goal is to add NixOS-specific instructions to Development/BuildingOnLinux - The Document Foundation Wiki

I work for TDF as a mentor.

Oof, sorry, I was unable to find the file you referenced, apparently beause GitHub’s search is poop. Now I found it and it was not searchable without viewing the raw version. I will look into it, cheers.

Ah, right, this is something best navigated by unpacking the channel expressions or using a checkout.

The end goal is to add NixOS-specific instructions to Development/BuildingOnLinux - The Document Foundation Wiki

I work for TDF as a mentor.

Oh, I misunderstood, I kind of assumed you wanted to do a «standby Draft PR» with LibreOffice master to convert to a PR for updating Fresh once a release occurs. In that case you would need a checkout anyway, so I thought filename is enough as «find» would find it pretty quickly.

Sure, for minimal development setup instructions it makes sense to have a single file (maybe still better to have two: libreoffice.nix close to Nixpkgs default,nix and also default.nix to do the resulting pretty long callPackage).

Thanks for doing this, sounds cool!

Yay, I got it to build yesterday!

However, in all my enthusiasm to get a working build, I overlooked the fact that this sandboxed approach is unusable for LibreOffice development. The LibreOffice build system does incremental builds by default, so a localised code change might take only under 1 minute to build. With the wholesale copying of the source, I am forced to do a full build every time (depending on the hardware & build options this can take anything from 30 mins to several hours).

I did some web searches and it doesn’t seem so straightforward. Could this be achieved now using nix-shell somehow? It looks like content-addressed store would make this simple, am I correct?

I did some web searches and it doesn’t seem so straightforward. Could this be achieved now using nix-shell somehow? It looks like content-addressed store would make this simple, am I correct?

Not straightforward to fix with nix-build.

This is done without full sandbox etc., using nix-shell or (not yet fully stabilised feature) nix develop. On the bright side, they are normally defined based on a working nix-build expression, so you were working in the correct direction anyway.

Content-addressed store won’t help, because approximately all build systems are complex and opaque, so it’s not easy to create a Nix store entry per file compiled or something. And if you can make each compiled file into its own micro-package, then even without CAS you will get a lot of improvement.

1 Like

I set things up so I have nix 2.4pre and can use nix develop. What should I do to be able to use it? It seems to want flakes. Do I have to convert the default.nix to a flake? Also, I don’t know how I could integrate this expression that I was using with nix-build into the default.nix itself:

with import <nixpkgs> {}; libsForQt5.callPackage ./default.nix { ArchiveZip = perlPackages.ArchiveZip; IOCompress = perlPackages.IOCompress; zip = zip.override { enableNLS = false; }; harfbuzz = harfbuzz.override { withIcu = true; withGraphite2 = true; }; }

Here is my simplified default.nix:

with import <nixpkgs> {};
{ stdenv, fetchurl, fetchpatch, lib, pam, python3, libxslt, perl, ArchiveZip, gettext
, IOCompress, zlib, libjpeg, expat, freetype, libwpd
, libxml2, db, curl, fontconfig, libsndfile, neon
, bison, flex, zip, unzip, gtk3, libmspack, getopt, file, cairo, which
, icu, boost, box2d, jdk, ant, cups, xorg, libcmis, fontforge
, openssl, gperf, cppunit, poppler, utillinux
, 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
, pkgconfig, bluez5, libtool, carlito
, libatomic_ops, graphite2, harfbuzz, libodfgen, libzmf
, librevenge, libe-book, libmwaw, glm, gst_all_1
, gdb, commonsLogging, librdf_rasqal, wrapGAppsHook
, gnome3, glib, ncurses, epoxy, gpgme
, langs ? [ "en-US" ]
, withHelp ? false
, kdeIntegration ? true, mkDerivation ? null, qtbase ? null, qtx11extras ? null
, ki18n ? null, kconfig ? null, kcoreaddons ? null, kio ? null, kwindowsystem ? null
} @ args:

let
  fontsConf = makeFontsConf {
    fontDirectories = [
      carlito dejavu_fonts
      freefont_ttf xorg.fontmiscmisc
      liberation_ttf_v1
      liberation_ttf_v2
    ];
  };
  clucene_core = clucene_core_2;
  lcms = lcms2;
  jdk = jdk11;

  langsSpaces = lib.concatStringsSep " " langs;

  mkDrv = if kdeIntegration then mkDerivation else stdenv.mkDerivation;

  srcs = {
    translations = /home/user/libreoffice/translations;
    help = /home/user/libreoffice/help;
  };
in (mkDrv rec {
  name= "libreoffice-master";
  pname = "libreoffice-master";

  src = /home/user/libreoffice;

  outputs = [ "out" "dev" ];

  # For some reason librdf_redland sometimes refers to rasqal.h instead
  # of rasqal/rasqal.h
  NIX_CFLAGS_COMPILE = [
    "-I${librdf_rasqal}/include/rasqal"
  ] ++ lib.optionals stdenv.isx86_64 [ "-mno-fma" "-mno-avx" ]
  # https://bugs.documentfoundation.org/show_bug.cgi?id=78174#c10
  ++ [ "-fno-visibility-inlines-hidden" ];

  ### QT/KDE
  #
  # We have to resort to the ugly patching of configure.ac as it assumes that
  # the first directory that contains headers and libraries during the check
  # contains all the relevant headers/libs which doesn't work with both as they
  # are in multiple directories due to each having their own derivation.
  postPatch = let
    inc = e: path:
      "${lib.getDev e}/include/KF5/${path}";
    libs = list:
      lib.concatMapStringsSep " " (e: "-L${lib.getLib e}/lib") list;
  in ''
    substituteInPlace shell/source/unix/exec/shellexec.cxx \
      --replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"}

    # configure checks for header 'gpgme++/gpgmepp_version.h',
    # and if it is found (no matter where) uses a hardcoded path
    # in what presumably is an effort to make it possible to write
    # '#include <context.h>' instead of '#include <gpgmepp/context.h>'.
    #
    # Fix this path to point to where the headers can actually be found instead.
    substituteInPlace configure.ac --replace \
      'GPGMEPP_CFLAGS=-I/usr/include/gpgme++' \
      'GPGMEPP_CFLAGS=-I${gpgme.dev}/include/gpgme++'
  '' + lib.optionalString kdeIntegration ''
      substituteInPlace configure.ac \
        --replace '$QT5INC'             ${qtbase.dev}/include \
        --replace '$QT5LIB'             ${qtbase.out}/lib \
        --replace '-I$qt5_incdir '      '-I${qtx11extras.dev}/include '\
        --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;
  dontUseCmakeBuildDir = true;

  preConfigure = ''
    configureFlagsArray=(
      "--with-parallelism=$NIX_BUILD_CORES"
      "--with-lang=${langsSpaces}"
    );

    chmod a+x ./bin/unpack-sources
    patchShebangs .

    # This is required as some cppunittests require fontconfig configured
    cp "${fontsConf}" fonts.conf
    sed -e '/include/i<include>${carlito}/etc/fonts/conf.d</include>' -i fonts.conf
    export FONTCONFIG_FILE="$PWD/fonts.conf"

    NOCONFIGURE=1 ./autogen.sh
  '';

  postConfigure =
    # Test fixups
    # May need to be revisited/pruned, left alone for now.
    ''
      # unit test sd_tiledrendering seems to be fragile
      # https://nabble.documentfoundation.org/libreoffice-5-0-failure-in-CUT-libreofficekit-tiledrendering-td4150319.html
      echo > ./sd/CppunitTest_sd_tiledrendering.mk
      sed -e /CppunitTest_sd_tiledrendering/d -i sd/Module_sd.mk
      # Pivot chart tests. Fragile.
      sed -e '/CPPUNIT_TEST(testRoundtrip)/d' -i chart2/qa/extras/PivotChartTest.cxx
      sed -e '/CPPUNIT_TEST(testPivotTableMedianODS)/d' -i sc/qa/unit/pivottable_filters_test.cxx
      # one more fragile test?
      sed -e '/CPPUNIT_TEST(testTdf96536);/d' -i sw/qa/extras/uiwriter/uiwriter.cxx
      # this I actually hate, this should be a data consistency test!
      sed -e '/CPPUNIT_TEST(testTdf115013);/d' -i sw/qa/extras/uiwriter/uiwriter.cxx
      # rendering-dependent test
      sed -e '/CPPUNIT_ASSERT_EQUAL(11148L, pOleObj->GetLogicRect().getWidth());/d ' -i sc/qa/unit/subsequent_filters-test.cxx
      # tilde expansion in path processing checks the existence of $HOME
      sed -e 's@OString sSysPath("~/tmp");@& return ; @' -i sal/qa/osl/file/osl_File.cxx
      # fails on systems using ZFS, see https://github.com/NixOS/nixpkgs/issues/19071
      sed -e '/CPPUNIT_TEST(getSystemPathFromFileURL_005);/d' -i './sal/qa/osl/file/osl_File.cxx'
      # rendering-dependent: on my computer the test table actually doesn't fit…
      # interesting fact: test disabled on macOS by upstream
      sed -re '/DECLARE_WW8EXPORT_TEST[(]testTableKeep, "tdf91083.odt"[)]/,+5d' -i ./sw/qa/extras/ww8export/ww8export.cxx
      # Segfault on DB access — maybe temporarily acceptable for a new version of Fresh?
      sed -e 's/CppunitTest_dbaccess_empty_stdlib_save//' -i ./dbaccess/Module_dbaccess.mk
      # one more fragile test?
      sed -e '/CPPUNIT_TEST(testTdf77014);/d' -i sw/qa/extras/uiwriter/uiwriter.cxx
      # rendering-dependent tests
      sed -e '/CPPUNIT_TEST(testCustomColumnWidthExportXLSX)/d' -i sc/qa/unit/subsequent_export-test.cxx
      sed -e '/CPPUNIT_TEST(testColumnWidthExportFromODStoXLSX)/d' -i sc/qa/unit/subsequent_export-test.cxx
      sed -e '/CPPUNIT_TEST(testChartImportXLS)/d' -i sc/qa/unit/subsequent_filters-test.cxx
      sed -e '/CPPUNIT_TEST(testLegacyCellAnchoredRotatedShape)/d' -i sc/qa/unit/filters-test.cxx
      sed -zre 's/DesktopLOKTest::testGetFontSubset[^{]*[{]/& return; /' -i desktop/qa/desktop_lib/test_desktop_lib.cxx
      sed -z -r -e 's/DECLARE_OOXMLEXPORT_TEST[(]testFlipAndRotateCustomShape,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
      sed -z -r -e 's/DECLARE_OOXMLEXPORT_TEST[(]tdf105490_negativeMargins,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlexport/ooxmlexport9.cxx
      sed -z -r -e 's/DECLARE_OOXMLIMPORT_TEST[(]testTdf112443,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlimport/ooxmlimport.cxx
      sed -z -r -e 's/DECLARE_RTFIMPORT_TEST[(]testTdf108947,[^)]*[)].[{]/& return;/' -i sw/qa/extras/rtfimport/rtfimport.cxx
      # not sure about this fragile test
      sed -z -r -e 's/DECLARE_OOXMLEXPORT_TEST[(]testTDF87348,[^)]*[)].[{]/& return;/' -i sw/qa/extras/ooxmlexport/ooxmlexport7.cxx
      # bunch of new Fresh failures. Sigh.
      sed -e '/CPPUNIT_TEST(testDocumentLayout);/d' -i './sd/qa/unit/import-tests.cxx'
      sed -e '/CPPUNIT_TEST(testErrorBarDataRangeODS);/d' -i './chart2/qa/extras/chart2export.cxx'
      sed -e '/CPPUNIT_TEST(testLabelStringODS);/d' -i './chart2/qa/extras/chart2export.cxx'
      sed -e '/CPPUNIT_TEST(testAxisNumberFormatODS);/d' -i './chart2/qa/extras/chart2export.cxx'
      sed -e '/CPPUNIT_TEST(testBackgroundImage);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testFdo84043);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf97630);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf80020);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf62176);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTransparentBackground);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedPdf);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedText);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf98477);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testAuthorField);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf50499);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf100926);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testPageWithTransparentBackground);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTextRotation);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf113818);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf119629);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf113822);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(test);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testConditionalFormatExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF16LErtlSHA1);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF8SHA1);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF8SHA256ODF12);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_UTF8SHA256W3C);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testProtectionKeyODS_XL_SHA1);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testColorScaleExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testDataBarExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testNamedRangeBugfdo62729);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testRichTextExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testFormulaRefSheetNameODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCellValuesExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCellNoteExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testFormatExportODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedChartODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCellAnchoredGroupXLS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testCeilingFloorODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testRelativePathsODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testSheetProtectionODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testSwappedOutImageExport);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testLinkedGraphicRT);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testImageWithSpecialID);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testAbsNamedRangeHTML);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testMoveCellAnchoredShapesODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testRefStringUnspecified);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testHeaderImageODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testTdf88657ODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testExponentWithoutSignFormatXLSX);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testHiddenRepeatedRowsODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testHyperlinkTargetFrameODS);/d' -i './sc/qa/unit/subsequent_export-test.cxx'
      sed -e '/CPPUNIT_TEST(testTdf105739);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testPageBitmapWithTransparency);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf115005);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf115005_FallBack_Images_On);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf115005_FallBack_Images_Off);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testTdf44774);/d' -i './sd/qa/unit/misc-tests.cxx'
      sed -e '/CPPUNIT_TEST(testTdf38225);/d' -i './sd/qa/unit/misc-tests.cxx'
      sed -e '/CPPUNIT_TEST(testAuthorField);/d' -i './sd/qa/unit/export-tests-ooxml2.cxx'
      sed -e '/CPPUNIT_TEST(testAuthorField);/d' -i './sd/qa/unit/export-tests.cxx'
      sed -e '/CPPUNIT_TEST(testFdo85554);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e '/CPPUNIT_TEST(testEmbeddedDataSource);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e '/CPPUNIT_TEST(testTdf96479);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e '/CPPUNIT_TEST(testInconsistentBookmark);/d' -i './sw/qa/extras/uiwriter/uiwriter.cxx'
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/ooxmlexport/ooxmlexport9.cxx"
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/ooxmlexport/ooxmlencryption.cxx"
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/odfexport/odfexport.cxx"
      sed -e "s/DECLARE_SW_ROUNDTRIP_TEST(\([_a-zA-Z0-9.]\+\)[, ].*, *\([_a-zA-Z0-9.]\+\))/class \\1: public \\2 { public: void verify() override; }; void \\1::verify() /" -i "sw/qa/extras/unowriter/unowriter.cxx"
    ''
    # This to avoid using /lib:/usr/lib at linking
    + ''
    sed -i '/gb_LinkTarget_LDFLAGS/{ n; /rpath-link/d;}' solenv/gbuild/platform/unxgcc.mk

    find -name "*.cmd" -exec sed -i s,/lib:/usr/lib,, {} \;
    '';

  makeFlags = [ "SHELL=${bash}/bin/bash" ];

  enableParallelBuilding = true;

  buildPhase = ''
    make
  '';

  doCheck = false;

  configureFlags = [
    (if withHelp then "" else "--without-help")
    "--with-boost=${boost.dev}"
    "--with-boost-libdir=${boost.out}/lib"
    "--with-beanshell-jar=${bsh}"
    "--with-vendor=NixOS"
    "--with-commons-logging-jar=${commonsLogging}/share/java/commons-logging-1.2.jar"
    "--disable-report-builder"
    "--disable-online-update"
    "--enable-python=system"
    "--enable-dbus"
    "--enable-release-build"
    "--enable-epm"
    "--with-jdk-home=${jdk.home}"
    "--with-ant-home=${ant}/lib/ant"
    "--with-system-cairo"
    "--with-system-libs"
    "--with-system-headers"
    "--with-system-openssl"
    "--with-system-libabw"
    "--with-system-libcmis"
    "--with-system-libwps"
    "--with-system-openldap"
    "--with-system-coinmp"
    "--with-system-clucene"

    # Without these, configure does not finish
    "--without-junit"

    # Schema files for validation are not included in the source tarball
    "--without-export-validation"

    # We do tarball prefetching ourselves
    "--disable-fetch-external"
    "--enable-build-opensymbol"

    # I imagine this helps. Copied from go-oo.
    # Modified on every upgrade, though
    "--disable-odk"
    "--disable-postgresql-sdbc"
    "--disable-firebird-sdbc"
    "--without-fonts"
    "--without-myspell-dicts"
    "--without-doxygen"

    # TODO: package these as system libraries
    "--with-system-beanshell"
    "--without-system-hsqldb"
    "--without-system-altlinuxhyph"
    "--without-system-lpsolve"
    "--without-system-libetonyek"
    "--without-system-libfreehand"
    "--without-system-liblangtag"
    "--without-system-libmspub"
    "--without-system-libpagemaker"
    "--without-system-libstaroffice"
    "--without-system-libepubgen"
    "--without-system-libqxp"
    "--without-system-mdds" # we have mdds but our version is too new
    # https://github.com/NixOS/nixpkgs/commit/5c5362427a3fa9aefccfca9e531492a8735d4e6f
    "--without-system-orcus"
    "--without-system-qrcodegen"
    "--without-system-xmlsec"
    "--without-system-neon"
    "--without-system-libnumbertext"
  ] ++ lib.optionals kdeIntegration [
    "--enable-kf5"
    "--enable-qt5"
  ];

  checkPhase = ''
    make unitcheck
    make slowcheck
  '';

  nativeBuildInputs = [
    gdb fontforge autoconf automake bison pkgconfig libtool
  ] ++ lib.optional (!kdeIntegration) wrapGAppsHook;

  buildInputs = with xorg;
    [ ant perlPackages.ArchiveZip boost box2d cairo clucene_core
      perlPackages.IOCompress cppunit cups curl db dbus-glib expat file flex fontconfig
      freetype getopt gperf gtk3
      hunspell icu jdk lcms libcdr libexttextcat unixODBC libjpeg
      libmspack librdf_redland librsvg libsndfile libvisio libwpd libwpg libX11
      libXaw libXext libXi libXinerama libxml2 libxslt libXtst
      libXdmcp libpthreadstubs libGLU libGL mythes
      glib libmysqlclient
      neon nspr nss openldap openssl pam perl pkgconfig poppler
      python3 sane-backends unzip which zip zlib
      mdds bluez5 libcmis libwps libabw libzmf
      libxshmfence libatomic_ops graphite2 harfbuzz gpgme utillinux
      librevenge libe-book libmwaw glm ncurses epoxy
      libodfgen CoinMP librdf_rasqal gnome3.adwaita-icon-theme gettext
    ]
    ++ (with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good ])
    ++ lib.optional kdeIntegration [ qtbase qtx11extras kcoreaddons kio ];

  passthru = {
    inherit srcs jdk;
  };

  requiredSystemFeatures = [ "big-parallel" ];

  meta = with lib; {
    description = "Comprehensive, professional-quality productivity suite, a variant of openoffice.org";
    homepage = "https://libreoffice.org/";
    license = licenses.lgpl3;
    maintainers = with maintainers; [ raskin ];
    platforms = platforms.linux;
  };
})

I have no idea about nix-develop and flakes. I think that nix-shell '<nixpkgs> -A libreoffice-fresh.libreoffice' (punching through the wrapper), or indeed using your default-calling file nix-shell ./call-libreoffice-default.nix should work somehow. There is some brief description of nix-shell in Introduction - Nix Reference Manual

Nixpkgs is already a flake if you want to treat it like one, so I guess there should be a reasonable way to use nix develop here, but I don’t know the details

Thanks. Now I tried with nix-shell, but it throws
cannot auto-call a function that has an argument without a default value ('stdenv')

Thanks. Now I tried with nix-shell, but it throws
cannot auto-call a function that has an argument without a default value ('stdenv')

I think it tries to use default.nix and you should either tell it to use the loader file that runs callPackage on default.nix, or call that loader file shell.nix

Thanks a lot, I created a file call-nix-shell-default.nix with

with import <nixpkgs> {}; libsForQt5.callPackage ./nix-shell-default.nix { ArchiveZip = perlPackages.ArchiveZip; IOCompress = perlPackages.IOCompress; zip = zip.override { enableNLS = false; }; harfbuzz = harfbuzz.override { withIcu = true; withGraphite2 = true; }; }

and then ran nix-shell ./call-nix-shell-default.nix. After trying autogen.sh it became clear the shell was working! I already had my own autogen.input quite far along and after a couple of tweaks it finished OK. I would have to do some figuring out to be able to use system Boost and kf5/qt5 seem even trickier, but it’s a nice start!

If I run my built LibreOffice with the gtk3 backend, opening a file dialog causes a crash with
GLib-GIO-ERROR **: 08:35:15.201: No GSettings schemas are installed on the system
I can use file dialogs just fine with gen backend, but it would be nice to be able to use gtk3.
I know about wrap-gapps-hook, but how could I solve this outside nixpkg context?