Skip to content

Commit

Permalink
folly: split outputs to reduce closure sizes
Browse files Browse the repository at this point in the history
This shaves off a 100MiB+ `boost.dev` dependence from `folly.out`, which
would benefit all downstream packages that dynamically link to folly.

Upstream's cmake configuration is not suitable for split packages, and
some tweaks are applied for it to work; these are taken from:

- 04384d5
- 8d712cc

See: https://github.com/jtojnar/cmake-snips
  • Loading branch information
bryango committed Jan 5, 2024
1 parent 10b0f19 commit 960a1f6
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions pkgs/development/libraries/folly/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
, boost
, cmake
, double-conversion
, fetchpatch
, fmt_8
, gflags
, glog
Expand Down Expand Up @@ -64,12 +63,21 @@ stdenv.mkDerivation rec {
# temporary hack until folly builds work on aarch64,
# see https://github.com/facebook/folly/issues/1880
"-DCMAKE_LIBRARY_ARCHITECTURE=${if stdenv.isx86_64 then "x86_64" else "dummy"}"

# ensure correct dirs in $dev/lib/pkgconfig/libfolly.pc
# see https://github.com/NixOS/nixpkgs/issues/144170
"-DCMAKE_INSTALL_INCLUDEDIR=include"
"-DCMAKE_INSTALL_LIBDIR=lib"
];

# split outputs to reduce downstream closure sizes
outputs = [ "out" "dev" ];

# patch prefix issues again
# see https://github.com/NixOS/nixpkgs/issues/144170
postFixup = ''
substituteInPlace "$out"/lib/pkgconfig/libfolly.pc \
--replace '=''${prefix}//' '=/' \
--replace '=''${exec_prefix}//' '=/'
substituteInPlace $dev/lib/cmake/${pname}/${pname}-targets-release.cmake \
--replace '$'{_IMPORT_PREFIX}/lib/ $out/lib/
'';

# folly-config.cmake, will `find_package` these, thus there should be
Expand Down

0 comments on commit 960a1f6

Please sign in to comment.