Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at domenkozar-patch-1 55 lines 1.7 kB view raw
1{ lib, stdenv, fetchFromGitHub, cmake, ninja 2, secureBuild ? false 3}: 4 5let 6 soext = stdenv.hostPlatform.extensions.sharedLibrary; 7in 8stdenv.mkDerivation rec { 9 pname = "mimalloc"; 10 version = "2.0.9"; 11 12 src = fetchFromGitHub { 13 owner = "microsoft"; 14 repo = pname; 15 rev = "v${version}"; 16 sha256 = "sha256-0gX0rEOWT6Lp5AyRyrK5GPTBvAqc5SxSaNJOc5GIgKc="; 17 }; 18 19 doCheck = true; 20 preCheck = let 21 ldLibraryPathEnv = if stdenv.isDarwin then "DYLD_LIBRARY_PATH" else "LD_LIBRARY_PATH"; 22 in '' 23 export ${ldLibraryPathEnv}="$(pwd)/build:''${${ldLibraryPathEnv}}" 24 ''; 25 26 nativeBuildInputs = [ cmake ninja ]; 27 cmakeFlags = [ "-DMI_INSTALL_TOPLEVEL=ON" ] ++ lib.optionals secureBuild [ "-DMI_SECURE=ON" ]; 28 29 postInstall = let 30 rel = lib.versions.majorMinor version; 31 suffix = if stdenv.isLinux then "${soext}.${rel}" else ".${rel}${soext}"; 32 in '' 33 # first, move headers and cmake files, that's easy 34 mkdir -p $dev/lib 35 mv $out/lib/cmake $dev/lib/ 36 37 find $dev $out -type f 38 '' + (lib.optionalString secureBuild '' 39 # pretend we're normal mimalloc 40 ln -sfv $out/lib/libmimalloc-secure${suffix} $out/lib/libmimalloc${suffix} 41 ln -sfv $out/lib/libmimalloc-secure${suffix} $out/lib/libmimalloc${soext} 42 ln -sfv $out/lib/libmimalloc-secure.a $out/lib/libmimalloc.a 43 ln -sfv $out/lib/mimalloc-secure.o $out/lib/mimalloc.o 44 ''); 45 46 outputs = [ "out" "dev" ]; 47 48 meta = with lib; { 49 description = "Compact, fast, general-purpose memory allocator"; 50 homepage = "https://github.com/microsoft/mimalloc"; 51 license = licenses.bsd2; 52 platforms = platforms.unix; 53 maintainers = with maintainers; [ kamadorueda thoughtpolice ]; 54 }; 55}