1{ lib, stdenv, fetchFromGitHub, cmake, boost, gmp, openssl, pkg-config }:
2
3stdenv.mkDerivation rec {
4 pname = "libff";
5 version = "1.0.0";
6
7 src = fetchFromGitHub {
8 owner = "scipr-lab";
9 repo = "libff";
10 rev = "v${version}";
11 sha256 = "0dczi829497vqlmn6n4fgi89bc2h9f13gx30av5z2h6ikik7crgn";
12 fetchSubmodules = true;
13 };
14
15 cmakeFlags = [ "-DWITH_PROCPS=Off" ];
16
17 # CMake is hardcoded to always build static library which causes linker
18 # failure for Haskell applications depending on haskellPackages.hevm on macOS.
19 postPatch = lib.optionalString stdenv.isDarwin ''
20 substituteInPlace libff/CMakeLists.txt --replace "STATIC" "SHARED"
21 '';
22
23 nativeBuildInputs = [ cmake pkg-config ];
24 buildInputs = [ boost gmp openssl ];
25
26 meta = with lib; {
27 description = "C++ library for Finite Fields and Elliptic Curves";
28 changelog = "https://github.com/scipr-lab/libff/blob/develop/CHANGELOG.md";
29 homepage = "https://github.com/scipr-lab/libff";
30 license = licenses.mit;
31 platforms = platforms.unix;
32 maintainers = with maintainers; [ arturcygan ];
33 };
34}