2023-02-16 17:41:37 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
2020-12-25 13:55:36 +00:00
|
|
|
, fetchFromGitHub
|
|
|
|
, boost
|
2022-02-20 05:27:41 +00:00
|
|
|
, cmake
|
2020-12-25 13:55:36 +00:00
|
|
|
, double-conversion
|
2022-02-20 05:27:41 +00:00
|
|
|
, fmt_8
|
2020-12-25 13:55:36 +00:00
|
|
|
, gflags
|
2022-02-20 05:27:41 +00:00
|
|
|
, glog
|
|
|
|
, libevent
|
2020-12-25 13:55:36 +00:00
|
|
|
, libiberty
|
2022-02-20 05:27:41 +00:00
|
|
|
, libunwind
|
2020-12-25 13:55:36 +00:00
|
|
|
, lz4
|
|
|
|
, openssl
|
|
|
|
, pkg-config
|
2022-02-20 05:27:41 +00:00
|
|
|
, xz
|
|
|
|
, zlib
|
|
|
|
, zstd
|
2022-07-18 16:21:45 +00:00
|
|
|
, jemalloc
|
2022-02-20 05:27:41 +00:00
|
|
|
, follyMobile ? false
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
# for passthru.tests
|
|
|
|
, python3
|
|
|
|
, watchman
|
2020-12-25 13:55:36 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-02-20 05:27:41 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "folly";
|
2024-04-21 15:54:59 +00:00
|
|
|
version = "2024.03.11.00";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "facebook";
|
|
|
|
repo = "folly";
|
|
|
|
rev = "v${version}";
|
2024-04-21 15:54:59 +00:00
|
|
|
sha256 = "sha256-INvWTw27fmVbKQIT9ebdRGMCOIzpc/NepRN2EnKLJx0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2020-12-25 13:55:36 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
pkg-config
|
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
# See CMake/folly-deps.cmake in the Folly source tree.
|
|
|
|
buildInputs = [
|
|
|
|
boost
|
|
|
|
double-conversion
|
|
|
|
glog
|
|
|
|
gflags
|
|
|
|
libevent
|
|
|
|
libiberty
|
|
|
|
openssl
|
2020-12-25 13:55:36 +00:00
|
|
|
lz4
|
2021-04-05 15:23:46 +00:00
|
|
|
xz
|
2020-12-25 13:55:36 +00:00
|
|
|
zlib
|
|
|
|
libunwind
|
2022-02-20 05:27:41 +00:00
|
|
|
fmt_8
|
|
|
|
zstd
|
2022-07-18 16:21:45 +00:00
|
|
|
] ++ lib.optional stdenv.isLinux jemalloc;
|
|
|
|
|
|
|
|
# jemalloc headers are required in include/folly/portability/Malloc.h
|
|
|
|
propagatedBuildInputs = lib.optional stdenv.isLinux jemalloc;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = toString [ "-DFOLLY_MOBILE=${if follyMobile then "1" else "0"}" "-fpermissive" ];
|
2023-02-16 17:41:37 +00:00
|
|
|
cmakeFlags = [
|
|
|
|
"-DBUILD_SHARED_LIBS=ON"
|
|
|
|
|
|
|
|
# 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"}"
|
2024-01-25 14:12:00 +00:00
|
|
|
|
|
|
|
# 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"
|
2024-04-21 15:54:59 +00:00
|
|
|
] ++ lib.optional (stdenv.isDarwin && stdenv.isx86_64) [
|
|
|
|
"-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13"
|
2023-02-16 17:41:37 +00:00
|
|
|
];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-01-25 14:12:00 +00:00
|
|
|
# split outputs to reduce downstream closure sizes
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
|
|
|
# patch prefix issues again
|
|
|
|
# see https://github.com/NixOS/nixpkgs/issues/144170
|
2022-09-30 11:47:45 +00:00
|
|
|
postFixup = ''
|
2024-01-25 14:12:00 +00:00
|
|
|
substituteInPlace $dev/lib/cmake/${pname}/${pname}-targets-release.cmake \
|
|
|
|
--replace '$'{_IMPORT_PREFIX}/lib/ $out/lib/
|
2022-09-30 11:47:45 +00:00
|
|
|
'';
|
|
|
|
|
2022-09-09 14:08:57 +00:00
|
|
|
passthru = {
|
2024-02-29 20:09:43 +00:00
|
|
|
# folly-config.cmake, will `find_package` these, thus there should be
|
|
|
|
# a way to ensure abi compatibility.
|
2022-09-09 14:08:57 +00:00
|
|
|
inherit boost;
|
|
|
|
fmt = fmt_8;
|
2024-02-29 20:09:43 +00:00
|
|
|
|
|
|
|
tests = {
|
|
|
|
inherit watchman;
|
|
|
|
inherit (python3.pkgs) django pywatchman;
|
|
|
|
};
|
2022-09-09 14:08:57 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Open-source C++ library developed and used at Facebook";
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://github.com/facebook/folly";
|
|
|
|
license = licenses.asl20;
|
|
|
|
# 32bit is not supported: https://github.com/facebook/folly/issues/103
|
2022-05-18 14:49:53 +00:00
|
|
|
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
maintainers = with maintainers; [ abbradar pierreis ];
|
|
|
|
};
|
2022-02-20 05:27:41 +00:00
|
|
|
}
|