1{ lib, stdenv, fetchFromGitHub, cmake, boost, gmp, openssl, pkg-config
2, enableStatic ? stdenv.hostPlatform.isStatic }:
3
4stdenv.mkDerivation rec {
5 pname = "libff";
6 version = "0.2.1";
7
8 src = fetchFromGitHub {
9 owner = "scipr-lab";
10 repo = "libff";
11 rev = "v${version}";
12 sha256 = "0dczi829497vqlmn6n4fgi89bc2h9f13gx30av5z2h6ikik7crgn";
13 fetchSubmodules = true;
14 };
15
16 cmakeFlags = [ "-DWITH_PROCPS=Off" ]
17 ++ lib.optionals stdenv.isAarch64 [ "-DCURVE=ALT_BN128" "-DUSE_ASM=OFF" ];
18
19 postPatch = lib.optionalString (!enableStatic) ''
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}