Commit 8137c100 authored by 7c6f434c's avatar 7c6f434c
Browse files

libreoffice-*: nixfmt the default.nix to avoid CI issues

parent 883821eb
Loading
Loading
Loading
Loading
+527 −444
Original line number Diff line number Diff line
{ stdenv
, fetchurl
, fetchgit
, fetchpatch2
, lib
, pam
, python311
, libxslt
, perl
, perlPackages
, box2d
, gettext
, zlib
, libjpeg
, liblangtag
, expat
, freetype
, libwpd
, libxml2
, db
, curl
, fontconfig
, libsndfile
, neon
, bison
, flex
, zip
, unzip
, gtk3
, libmspack
, getopt
, file
, cairo
, which
, icu
, boost
, jdk21
, ant
, cups
, xorg
, fontforge
, jre21_minimal
, openssl
, gperf
, cppunit
, poppler
, util-linux
, librsvg
, libGLU
, libGL
, bsh
, coinmp
, libwps
, libabw
, libargon2
, libmysqlclient
, autoconf
, automake
, openldap
, bash
, hunspell
, librdf_rasqal
, librdf_redland
, nss
, nspr
, libwpg
, dbus-glib
, clucene_core_2
, libcdr
, lcms2
, unixODBC
, mdds
, sane-backends
, mythes
, libexttextcat
, libvisio
, pkg-config
, bluez5
, libtool
, libatomic_ops
, graphite2
, harfbuzz
, libodfgen
, libzmf
, librevenge
, libe-book
, libmwaw
, glm
, gst_all_1
, gdb
, adwaita-icon-theme
, glib
, ncurses
, libepoxy
, gpgme
, libwebp
, abseil-cpp
, libepubgen
, libetonyek
, liborcus
, libpng
, 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" ]
, withFonts ? false
, withHelp ? true
, kdeIntegration ? false
, qtbase ? null
, qtx11extras ? null
, qtwayland ? null
, ki18n ? null
, kconfig ? null
, kcoreaddons ? null
, kio ? null
, kwindowsystem ? null
, variant ? "fresh"
, symlinkJoin
, libpq
, makeFontsConf
, amiri
, caladea
, carlito
, culmus
, dejavu_fonts
, rubik
, liberation-sans-narrow
, liberation_ttf_v2
, libertine
, libertine-g
, noto-fonts
, noto-fonts-cjk-sans
, rhino
, lp_solve
, xmlsec
, libcmis
{
  stdenv,
  fetchurl,
  fetchgit,
  fetchpatch2,
  lib,
  pam,
  python311,
  libxslt,
  perl,
  perlPackages,
  box2d,
  gettext,
  zlib,
  libjpeg,
  liblangtag,
  expat,
  freetype,
  libwpd,
  libxml2,
  db,
  curl,
  fontconfig,
  libsndfile,
  neon,
  bison,
  flex,
  zip,
  unzip,
  gtk3,
  libmspack,
  getopt,
  file,
  cairo,
  which,
  icu,
  boost,
  jdk21,
  ant,
  cups,
  xorg,
  fontforge,
  jre21_minimal,
  openssl,
  gperf,
  cppunit,
  poppler,
  util-linux,
  librsvg,
  libGLU,
  libGL,
  bsh,
  coinmp,
  libwps,
  libabw,
  libargon2,
  libmysqlclient,
  autoconf,
  automake,
  openldap,
  bash,
  hunspell,
  librdf_rasqal,
  librdf_redland,
  nss,
  nspr,
  libwpg,
  dbus-glib,
  clucene_core_2,
  libcdr,
  lcms2,
  unixODBC,
  mdds,
  sane-backends,
  mythes,
  libexttextcat,
  libvisio,
  pkg-config,
  bluez5,
  libtool,
  libatomic_ops,
  graphite2,
  harfbuzz,
  libodfgen,
  libzmf,
  librevenge,
  libe-book,
  libmwaw,
  glm,
  gst_all_1,
  gdb,
  adwaita-icon-theme,
  glib,
  ncurses,
  libepoxy,
  gpgme,
  libwebp,
  abseil-cpp,
  libepubgen,
  libetonyek,
  liborcus,
  libpng,
  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"
  ],
  withFonts ? false,
  withHelp ? true,
  kdeIntegration ? false,
  qtbase ? null,
  qtx11extras ? null,
  qtwayland ? null,
  ki18n ? null,
  kconfig ? null,
  kcoreaddons ? null,
  kio ? null,
  kwindowsystem ? null,
  variant ? "fresh",
  symlinkJoin,
  libpq,
  makeFontsConf,
  amiri,
  caladea,
  carlito,
  culmus,
  dejavu_fonts,
  rubik,
  liberation-sans-narrow,
  liberation_ttf_v2,
  libertine,
  libertine-g,
  noto-fonts,
  noto-fonts-cjk-sans,
  rhino,
  lp_solve,
  xmlsec,
  libcmis,
  # 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
, qtmultimedia ? null
, qtquickcontrols ? null
, qtsvg ? null
, qttools ? null
, solid ? null
, sonnet ? null
  kauth ? null,
  kcompletion ? null,
  kconfigwidgets ? null,
  kglobalaccel ? null,
  kitemviews ? null,
  knotifications ? null,
  ktextwidgets ? null,
  kwidgetsaddons ? null,
  kxmlgui ? null,
  phonon ? null,
  qtdeclarative ? null,
  qtmultimedia ? null,
  qtquickcontrols ? null,
  qtsvg ? null,
  qttools ? null,
  solid ? null,
  sonnet ? null,
}:

assert builtins.elem variant [ "fresh" "still" "collabora" ];
assert builtins.elem variant [
  "fresh"
  "still"
  "collabora"
];

let
  inherit (lib)
    flatten flip
    concatMapStrings concatStringsSep
    getDev getLib
    optionals optionalString;
    flatten
    flip
    concatMapStrings
    concatStringsSep
    getDev
    getLib
    optionals
    optionalString
    ;

  fontsConf = makeFontsConf {
    fontDirectories = [
@@ -178,7 +216,12 @@ let
  };

  jre' = jre21_minimal.override {
    modules = [ "java.base" "java.desktop" "java.logging" "java.sql" ];
    modules = [
      "java.base"
      "java.desktop"
      "java.logging"
      "java.sql"
    ];
  };

  importVariant = f: import (./. + "/src-${variant}/${f}");
@@ -201,12 +244,15 @@ let
    ];
  };
  srcs = {
    third_party = map (x:
    third_party = map (
      x:
      (fetchurl {
        inherit (x) url sha256 name;
      }) // {
      })
      // {
        inherit (x) md5name md5;
      }) srcsAttributes.deps;
      }
    ) srcsAttributes.deps;
    translations = srcsAttributes.translations { inherit fetchurl fetchgit; };
    help = srcsAttributes.help { inherit fetchurl fetchgit; };
  };
@@ -216,7 +262,13 @@ let
  # See `postPatch` for details
  kdeDeps = symlinkJoin {
    name = "libreoffice-kde-dependencies-${version}";
    paths = flatten (map (e: [ (getDev e) (getLib e) ]) [
    paths = flatten (
      map
        (e: [
          (getDev e)
          (getLib e)
        ])
        [
          qtbase
          qtmultimedia
          qtx11extras
@@ -225,17 +277,20 @@ let
          ki18n
          kio
          kwindowsystem
    ]);
        ]
    );
  };
  tarballPath = "external/tarballs";

in stdenv.mkDerivation (finalAttrs: {
in
stdenv.mkDerivation (finalAttrs: {
  pname = "libreoffice";
  inherit version;

  src = srcsAttributes.main { inherit fetchurl fetchgit; };

  postUnpack = ''
  postUnpack =
    ''
      mkdir -v $sourceRoot/${tarballPath}

      ${flip concatMapStrings srcs.third_party (f: ''
@@ -243,18 +298,25 @@ in stdenv.mkDerivation (finalAttrs: {
        ln -sfv ${f} $sourceRoot/${tarballPath}/${f.name}
      '')}

  '' + (if (variant != "collabora") then ''
    ''
    + (
      if (variant != "collabora") then
        ''
          ln -sv ${srcs.help} $sourceRoot/${tarballPath}/${srcs.help.name}
          ln -svf ${srcs.translations} $sourceRoot/${tarballPath}/${srcs.translations.name}

          tar -xf ${srcs.help}
          tar -xf ${srcs.translations}
  '' else ''
        ''
      else
        ''
          cp -r --no-preserve=mode ${srcs.help}/. $sourceRoot/helpcontent2/
          cp -r --no-preserve=mode ${srcs.translations}/. $sourceRoot/translations/
  '');
        ''
    );

  patches = [
  patches =
    [
      # Skip some broken tests:
      # - tdf160386 does not fall back to a CJK font properly for some reason
      # - the remaining tests have notes in the patches
@@ -267,13 +329,15 @@ in stdenv.mkDerivation (finalAttrs: {

      # Revert part of https://github.com/LibreOffice/core/commit/6f60670877208612b5ea320b3677480ef6508abb that broke zlib linking
      ./readd-explicit-zlib-link.patch
  ] ++ lib.optionals (lib.versionOlder version "24.8") [
    ]
    ++ lib.optionals (lib.versionOlder version "24.8") [
      (fetchpatch2 {
        name = "icu74-compat.patch";
        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";
        hash = "sha256-OGBPIVQj8JTYlkKywt4QpH7ULAzKmet5jTLztGpIS0Y=";
      })
  ] ++ lib.optionals (variant == "collabora") [
    ]
    ++ lib.optionals (variant == "collabora") [
      ./fix-unpack-collabora.patch
    ];

@@ -303,7 +367,9 @@ in stdenv.mkDerivation (finalAttrs: {
    pkg-config
  ];

  buildInputs = finalAttrs.passthru.gst_packages ++ [
  buildInputs =
    finalAttrs.passthru.gst_packages
    ++ [
      # Make libpng not handle APNG images, so LibreOffice's own handler kicks in
      # This should be ordered first, so it gets picked up before any other
      # propagated libpng
@@ -405,14 +471,16 @@ in stdenv.mkDerivation (finalAttrs: {
      xmlsec
      zip
      zlib
  ] ++ optionals kdeIntegration [
    ]
    ++ optionals kdeIntegration [
      qtbase
      qtx11extras
      kcoreaddons
      kio
    ];

  preConfigure = ''
  preConfigure =
    ''
      configureFlagsArray=(
        "--with-parallelism=$NIX_BUILD_CORES"
        # here because we need to be very specific about spaces
@@ -422,7 +490,8 @@ in stdenv.mkDerivation (finalAttrs: {
      patchShebangs .

      NOCONFIGURE=1 ./autogen.sh
  '' + optionalString kdeIntegration ''
    ''
    + optionalString kdeIntegration ''
      # configure.ac assumes that the first directory that contains headers and
      # libraries during its checks contains *all* the relevant headers/libs which
      # obviously doesn't work for us, so we have 2 options:
@@ -442,7 +511,8 @@ in stdenv.mkDerivation (finalAttrs: {
      export KF${qtMajor}LIB=${kdeDeps}/lib
    '';

  configureFlags = [
  configureFlags =
    [
      # Explicitly passing in --host even on non-cross, because
      # LibreOffice will attempt to detect WSL and cross-compile
      # itself to Windows automatically, and we don't want it
@@ -519,21 +589,28 @@ in stdenv.mkDerivation (finalAttrs: {

      # is packaged but headers can't be found because there is no pkg-config file
      "--without-system-zxcvbn"
  ] ++ optionals kdeIntegration [
    ]
    ++ optionals kdeIntegration [
      "--enable-kf${qtMajor}"
      "--enable-qt${qtMajor}"
  ] ++ optionals (kdeIntegration && qtMajor == "5") [
    ]
    ++ optionals (kdeIntegration && qtMajor == "5") [
      "--enable-gtk3-kde5"
  ] ++ (if variant == "fresh" then [
    ]
    ++ (
      if variant == "fresh" then
        [
          "--with-system-rhino"
          "--with-rhino-jar=${rhino}/share/java/js.jar"

          "--without-system-java-websocket"
  ] else [
        ]
      else
        [
          # our Rhino is too new for older versions
          "--without-system-rhino"
  ]);

        ]
    );

  env = {
    # FIXME: this is a hack, because the right cflags are not being picked up
@@ -654,7 +731,9 @@ in stdenv.mkDerivation (finalAttrs: {
  # (see above), make sure these don't leak again by accident.
  # FIXME: disabled for kdeIntegration builds because the weird symlinkJoin setup
  # leaks all the -dev dependencies :(
  disallowedRequisites = lib.optionals (!kdeIntegration) (lib.concatMap (x: lib.optional (x?dev) x.dev) finalAttrs.buildInputs);
  disallowedRequisites = lib.optionals (!kdeIntegration) (
    lib.concatMap (x: lib.optional (x ? dev) x.dev) finalAttrs.buildInputs
  );

  requiredSystemFeatures = [ "big-parallel" ];

@@ -664,7 +743,11 @@ in stdenv.mkDerivation (finalAttrs: {
    homepage = "https://libreoffice.org/";
    # at least one jar in dependencies
    sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
    license = with lib.licenses; [ mpl20 lgpl3Plus asl20 ];
    license = with lib.licenses; [
      mpl20
      lgpl3Plus
      asl20
    ];
    maintainers = with lib.maintainers; [ raskin ];
    platforms = lib.platforms.linux;
    mainProgram = "libreoffice";