From 960a1f663ea7de24d6f4269d80292ec83466e2b6 Mon Sep 17 00:00:00 2001 From: Bryan Lai Date: Thu, 4 Jan 2024 12:43:00 +0800 Subject: [PATCH] folly: split outputs to reduce closure sizes 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: - https://github.com/NixOS/nixpkgs/commit/04384d56cf6d88bf6fd5fd74b0a39b312b104d42 - https://github.com/NixOS/nixpkgs/commit/8d712ccc161b11323e92e87e7057e461462d50e0 See: https://github.com/jtojnar/cmake-snips --- pkgs/development/libraries/folly/default.nix | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/pkgs/development/libraries/folly/default.nix b/pkgs/development/libraries/folly/default.nix index 4d98c163c6d3d..22d395785434a 100644 --- a/pkgs/development/libraries/folly/default.nix +++ b/pkgs/development/libraries/folly/default.nix @@ -4,7 +4,6 @@ , boost , cmake , double-conversion -, fetchpatch , fmt_8 , gflags , glog @@ -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