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