Skip to content

Commit

Permalink
Merge pull request NixOS#245361 from Ma27/libreoffice-fresh-closure
Browse files Browse the repository at this point in the history
libreoffice-fresh: strip away BUILDCONFIG, reduce runtime closure size by ~20%
  • Loading branch information
7c6f434c authored Jul 25, 2023
2 parents 5825210 + 408ece7 commit 54b701f
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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

16 changes: 16 additions & 0 deletions pkgs/applications/office/libreoffice/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 54b701f

Please sign in to comment.