Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at fix-function-merge 77 lines 2.1 kB view raw
1{ stdenv, lib, fetchFromGitHub, autoreconfHook }: 2 3stdenv.mkDerivation ( finalAttrs: { 4 pname = "blst"; 5 version = "0.3.13"; 6 7 src = fetchFromGitHub { 8 owner = "supranational"; 9 repo = "blst"; 10 rev = "v${finalAttrs.version}"; 11 hash = "sha256-+Ae2cCVVEXnV/ftVOApxDcXM3COf/4DXXd1AOuGS5uc="; 12 }; 13 14 buildPhase = '' 15 runHook preBuild 16 17 ./build.sh ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"} 18 ./build.sh -shared ${lib.optionalString stdenv.hostPlatform.isWindows "flavour=mingw64"} 19 20 runHook postBuild 21 ''; 22 installPhase = '' 23 runHook preInstall 24 25 mkdir -p $out/{lib,include} 26 for lib in libblst.{a,so,dylib}; do 27 if [ -f $lib ]; then 28 cp $lib $out/lib/ 29 fi 30 done 31 cp bindings/{blst.h,blst_aux.h} $out/include 32 33 for lib in blst.dll; do 34 if [ -f $lib ]; then 35 mkdir -p $out/bin 36 cp $lib $out/bin/ 37 fi 38 done 39 40 mkdir -p $out/lib/pkgconfig 41 cat <<EOF > $out/lib/pkgconfig/libblst.pc 42 prefix=$out 43 exec_prefix=''\\''${prefix} 44 libdir=''\\''${exec_prefix}/lib 45 includedir=''\\''${prefix}/include 46 47 Name: libblst 48 Description: ${finalAttrs.meta.description} 49 URL: ${finalAttrs.meta.homepage} 50 Version: ${finalAttrs.version} 51 52 Cflags: -I''\\''${includedir} 53 Libs: -L''\\''${libdir} -lblst 54 Libs.private: 55 EOF 56 57 runHook postInstall 58 ''; 59 60 # ensure we have the right install id set. Otherwise the library 61 # wouldn't be found during install. The alternative would be to work 62 # lib.optional stdenv.isDarwin "LDFLAGS=-Wl,-install_name,$(out)/lib/libblst.dylib"; 63 # into the setup.sh 64 postFixup = lib.optionalString stdenv.isDarwin '' 65 install_name_tool -id $out/lib/libblst.dylib $out/lib/libblst.dylib 66 ''; 67 68 doCheck = true; 69 70 meta = with lib; { 71 description = "Multilingual BLS12-381 signature library"; 72 homepage = "https://github.com/supranational/blst"; 73 license = licenses.isc; 74 maintainers = with maintainers; [ iquerejeta yvan-sraka ]; 75 platforms = platforms.all; 76 }; 77})