Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 110 lines 2.6 kB view raw
1{ lib 2, stdenv 3, overrideSDK 4, fetchFromGitHub 5, boost 6, cmake 7, double-conversion 8, fmt_8 9, gflags 10, glog 11, libevent 12, libiberty 13, libunwind 14, lz4 15, openssl 16, pkg-config 17, xz 18, zlib 19, zstd 20, jemalloc 21, follyMobile ? false 22 23# for passthru.tests 24, python3 25, watchman 26}: 27 28stdenv.mkDerivation rec { 29 pname = "folly"; 30 version = "2024.03.11.00"; 31 32 src = fetchFromGitHub { 33 owner = "facebook"; 34 repo = "folly"; 35 rev = "v${version}"; 36 sha256 = "sha256-INvWTw27fmVbKQIT9ebdRGMCOIzpc/NepRN2EnKLJx0="; 37 }; 38 39 nativeBuildInputs = [ 40 cmake 41 pkg-config 42 ]; 43 44 # See CMake/folly-deps.cmake in the Folly source tree. 45 buildInputs = [ 46 boost 47 double-conversion 48 glog 49 gflags 50 libevent 51 libiberty 52 openssl 53 lz4 54 xz 55 zlib 56 libunwind 57 fmt_8 58 zstd 59 ] ++ lib.optional stdenv.isLinux jemalloc; 60 61 # jemalloc headers are required in include/folly/portability/Malloc.h 62 propagatedBuildInputs = lib.optional stdenv.isLinux jemalloc; 63 64 env.NIX_CFLAGS_COMPILE = toString [ "-DFOLLY_MOBILE=${if follyMobile then "1" else "0"}" "-fpermissive" ]; 65 cmakeFlags = [ 66 "-DBUILD_SHARED_LIBS=ON" 67 68 # temporary hack until folly builds work on aarch64, 69 # see https://github.com/facebook/folly/issues/1880 70 "-DCMAKE_LIBRARY_ARCHITECTURE=${if stdenv.isx86_64 then "x86_64" else "dummy"}" 71 72 # ensure correct dirs in $dev/lib/pkgconfig/libfolly.pc 73 # see https://github.com/NixOS/nixpkgs/issues/144170 74 "-DCMAKE_INSTALL_INCLUDEDIR=include" 75 "-DCMAKE_INSTALL_LIBDIR=lib" 76 ] ++ lib.optional (stdenv.isDarwin && stdenv.isx86_64) [ 77 "-DCMAKE_OSX_DEPLOYMENT_TARGET=10.13" 78 ]; 79 80 # split outputs to reduce downstream closure sizes 81 outputs = [ "out" "dev" ]; 82 83 # patch prefix issues again 84 # see https://github.com/NixOS/nixpkgs/issues/144170 85 postFixup = '' 86 substituteInPlace $dev/lib/cmake/${pname}/${pname}-targets-release.cmake \ 87 --replace '$'{_IMPORT_PREFIX}/lib/ $out/lib/ 88 ''; 89 90 passthru = { 91 # folly-config.cmake, will `find_package` these, thus there should be 92 # a way to ensure abi compatibility. 93 inherit boost; 94 fmt = fmt_8; 95 96 tests = { 97 inherit watchman; 98 inherit (python3.pkgs) django pywatchman; 99 }; 100 }; 101 102 meta = with lib; { 103 description = "Open-source C++ library developed and used at Facebook"; 104 homepage = "https://github.com/facebook/folly"; 105 license = licenses.asl20; 106 # 32bit is not supported: https://github.com/facebook/folly/issues/103 107 platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; 108 maintainers = with maintainers; [ abbradar pierreis ]; 109 }; 110}