Created
February 17, 2023 17:30
-
-
Save cpcloud/a3b41aa60c9e91471b5ba028b8e8cb7f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# velox/flake.nix | |
# following https://www.breakds.org/post/nix-based-c++-workflow/ | |
{ | |
description = "A flake for building velox"; | |
inputs = { | |
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; | |
utils.url = "github:numtide/flake-utils"; | |
utils.inputs.nixpkgs.follows = "nixpkgs"; | |
}; | |
outputs = { self, nixpkgs, utils }: utils.lib.eachSystem [ | |
"x86_64-linux" | |
] | |
( | |
system: | |
let | |
pkgs = import nixpkgs { | |
inherit system; | |
overlays = [ | |
(final: prev: { | |
folly = final.callPackage ./folly.nix { }; | |
}) | |
]; | |
}; | |
in | |
{ | |
devShell = pkgs.mkShell rec { | |
name = "velox-sh"; | |
packages = with pkgs; [ | |
llvmPackages_14.clang | |
cmake | |
ccache | |
ninja | |
#checkinstall | |
git | |
wget | |
openssl | |
boost | |
icu | |
double-conversion | |
glog | |
#bz2 | |
gflags | |
gmock | |
libevent | |
lz4 | |
zstd | |
re2 | |
snappy | |
#lzo2 | |
bison | |
flex | |
tzdata | |
fmt_8 | |
folly | |
]; | |
}; | |
} | |
); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ lib | |
, stdenv | |
, fetchFromGitHub | |
, boost | |
, cmake | |
, double-conversion | |
, fetchpatch | |
, fmt_8 | |
, gflags | |
, glog | |
, libaio | |
, libdwarf | |
, libevent | |
, libiberty | |
, libsodium | |
, libunwind | |
, liburing | |
, lz4 | |
, ninja | |
, openssl | |
, pkg-config | |
, snappy | |
, xz | |
, zlib | |
, zstd | |
, jemalloc | |
, follyMobile ? false | |
}: | |
stdenv.mkDerivation rec { | |
pname = "folly"; | |
version = "2023.02.06.00"; | |
src = fetchFromGitHub { | |
owner = "facebook"; | |
repo = "folly"; | |
rev = "v${version}"; | |
sha256 = "sha256-37BoLs7LynuMuF7cdJtVOfZSs22PZr6DYNAVwigZghw="; | |
}; | |
nativeBuildInputs = [ | |
cmake | |
ninja | |
pkg-config | |
]; | |
# See CMake/folly-deps.cmake in the Folly source tree. | |
buildInputs = [ | |
boost | |
double-conversion | |
glog | |
gflags | |
libaio | |
libdwarf | |
liburing | |
libevent | |
libsodium | |
libiberty | |
openssl | |
snappy | |
lz4 | |
xz | |
zlib | |
libunwind | |
fmt_8 | |
zstd | |
] ++ lib.optional stdenv.isLinux jemalloc; | |
# jemalloc headers are required in include/folly/portability/Malloc.h | |
propagatedBuildInputs = lib.optional stdenv.isLinux jemalloc; | |
NIX_CFLAGS_COMPILE = [ | |
"-DFOLLY_MOBILE=${if follyMobile then "1" else "0"}" | |
"-fpermissive" | |
"-mavx2" | |
"-mfma" | |
"-mavx" | |
"-mf16c" | |
"-mlzcnt" | |
]; | |
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"}" | |
"-Wno-dev" | |
"-DCMAKE_CXX_STANDARD=17" | |
]; | |
postFixup = '' | |
substituteInPlace "$out"/lib/pkgconfig/libfolly.pc \ | |
--replace '=''${prefix}//' '=/' \ | |
--replace '=''${exec_prefix}//' '=/' | |
''; | |
# folly-config.cmake, will `find_package` these, thus there should be | |
# a way to ensure abi compatibility. | |
passthru = { | |
inherit boost; | |
fmt = fmt_8; | |
}; | |
meta = with lib; { | |
description = "An open-source C++ library developed and used at Facebook"; | |
homepage = "https://github.com/facebook/folly"; | |
license = licenses.asl20; | |
# 32bit is not supported: https://github.com/facebook/folly/issues/103 | |
platforms = [ "x86_64-linux" "x86_64-darwin" "aarch64-darwin" "aarch64-linux" ]; | |
maintainers = with maintainers; [ abbradar pierreis ]; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment