about summary refs log tree commit diff
path: root/pkgs/applications/office/libreoffice
diff options
context:
space:
mode:
authorMaximilian Bosch <maximilian@mbosch.me>2023-07-25 11:48:09 +0200
committerMaximilian Bosch <maximilian@mbosch.me>2023-07-25 18:05:49 +0200
commit408ece7d3d5b68f5c0d870abb936ee8950a1b9f9 (patch)
treedd1925ecbd766fe8314a738a808ccc96d91ffc18 /pkgs/applications/office/libreoffice
parent503101a4cf714fa3255548af3bc0f64d1bebb27a (diff)
libreoffice-fresh: strip away BUILDCONFIG, reduce runtime closure size by ~20%
In v7.5.x a change was introduced that writes the BUILDCONFIG into
`$out/lib/libreoffice/program/libsofficeapp.so` including the
`PKG_CONFIG_PATH` containing references to all `dev` outputs of library
dependencies:

    $ strings $(nix-build -A libreoffice-fresh)/lib/libreoffice/program/libsofficeapp.so|grep PKG_CONFIG_PATH
    [...], "BuildConfig": "[...] 'PKG_CONFIG_PATH=[...]'"

This isn't really needed because this information can also be obtained
by `nix derivation show`. Also, this causes a 20% larger runtime-closure
because of all the dev dependencies being referenced by the output and
thus downloaded whenever libreoffice is substituted somewhere. The
actual numbers look like this:

    $ nix path-info -Sh ./result-old
    /nix/store/3mzrqh4gg7v27vdrrap9dj3x8myysmyf-libreoffice-7.5.4.1-wrapped	  2.0G
    $ nix path-info -Sh ./result
    /nix/store/g5y60s0a2q2v6r58xcayv62z7fjfi816-libreoffice-7.5.4.1-wrapped	  1.6G

Only `libreoffice-fresh` is affected, `pkgs.libreoffice` isn't because
it still points to 7.4 whereas the problematic change was introduced in
7.5.

To make sure this doesn't get reintroduced by accident, the derivation
also prohibits now to reference any dev output from a build input.

[1] https://gerrit.libreoffice.org/c/core/+/141197
Diffstat (limited to 'pkgs/applications/office/libreoffice')
-rw-r--r--pkgs/applications/office/libreoffice/0001-Strip-away-BUILDCONFIG.patch32
-rw-r--r--pkgs/applications/office/libreoffice/default.nix16
2 files changed, 48 insertions, 0 deletions
diff --git a/pkgs/applications/office/libreoffice/0001-Strip-away-BUILDCONFIG.patch b/pkgs/applications/office/libreoffice/0001-Strip-away-BUILDCONFIG.patch
new file mode 100644
index 0000000000000..b477f902b2fb2
--- /dev/null
+++ b/pkgs/applications/office/libreoffice/0001-Strip-away-BUILDCONFIG.patch
@@ -0,0 +1,32 @@
+From 982d38084f08950863b55043f36ce5548bd73635 Mon Sep 17 00:00:00 2001
+From: Maximilian Bosch <maximilian@mbosch.me>
+Date: Mon, 24 Jul 2023 19:12:25 +0200
+Subject: [PATCH] Strip away BUILDCONFIG
+
+The `BuildConfig` field in `libsofficeapp.so` includes the entire
+`PKG_CONFIG_PATH` and subsequently references to a lot of `dev` outputs
+of library dependencies blowing up the closure.
+
+Since this is not strictly needed and the inputs are comprehensible via
+`nix derivation show`, this doesn't bring a real benefit in the case of
+nixpkgs anyways.
+---
+ desktop/source/lib/init.cxx | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
+index 8d830c0cbd00..fbdc86aa7115 100644
+--- a/desktop/source/lib/init.cxx
++++ b/desktop/source/lib/init.cxx
+@@ -7097,7 +7097,7 @@ static char* lo_getVersionInfo(SAL_UNUSED_PARAMETER LibreOfficeKit* /*pThis*/)
+         "\"ProductVersion\": \"%PRODUCTVERSION\", "
+         "\"ProductExtension\": \"%PRODUCTEXTENSION\", "
+         "\"BuildId\": \"%BUILDID\", "
+-        "\"BuildConfig\": \""  BUILDCONFIG  "\" "
++        "\"BuildConfig\": \"removed to avoid runtime dependencies against dev outputs of each dependency. Use 'nix derivation show' against the package to find out details about BuildConfig.\" "
+         "}"));
+ }
+ 
+-- 
+2.40.1
+
diff --git a/pkgs/applications/office/libreoffice/default.nix b/pkgs/applications/office/libreoffice/default.nix
index 518167cb33d12..cf769bf204780 100644
--- a/pkgs/applications/office/libreoffice/default.nix
+++ b/pkgs/applications/office/libreoffice/default.nix
@@ -214,6 +214,22 @@ in
     tar -xf ${srcs.translations}
   '';
 
+  # Remove build config to reduce the amount of `-dev` outputs in the
+  # runtime closure. This was introduced in upstream commit
+  # cbfac11330882c7d0a817b6c37a08b2ace2b66f4, so the patch doesn't apply
+  # for 7.4.
+  patches = lib.optionals (lib.versionAtLeast version "7.5") [
+    ./0001-Strip-away-BUILDCONFIG.patch
+  ];
+
+  # libreoffice tries to reference the BUILDCONFIG (e.g. PKG_CONFIG_PATH)
+  # in the binary causing the closure size to blow up because of many unnecessary
+  # dependencies to dev outputs. This behavior was patched away in nixpkgs
+  # (see above), make sure these don't leak again by accident.
+  disallowedRequisites = lib.concatMap
+    (x: lib.optional (x?dev) x.dev)
+    buildInputs;
+
   ### QT/KDE
   #
   # configure.ac assumes that the first directory that contains headers and