Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 21.11 49 lines 1.5 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.2"; 11 12 src = fetchFromGitHub { 13 owner = "microsoft"; 14 repo = pname; 15 rev = "v${version}"; 16 sha256 = "sha256-n4FGld3bq6ZOSLTzXcVlucCGbQ5/eSFbijU0dfBD/T0="; 17 }; 18 19 nativeBuildInputs = [ cmake ninja ]; 20 cmakeFlags = [ "-DMI_INSTALL_TOPLEVEL=ON" ] ++ lib.optional secureBuild [ "-DMI_SECURE=ON" ]; 21 22 postInstall = let 23 rel = lib.versions.majorMinor version; 24 suffix = if stdenv.isLinux then "${soext}.${rel}" else ".${rel}${soext}"; 25 in '' 26 # first, move headers and cmake files, that's easy 27 mkdir -p $dev/lib 28 mv $out/include $dev/include 29 mv $out/cmake $dev/lib/ 30 31 find $out/lib 32 '' + (lib.optionalString secureBuild '' 33 # pretend we're normal mimalloc 34 ln -sfv $out/lib/libmimalloc-secure${suffix} $out/lib/libmimalloc${suffix} 35 ln -sfv $out/lib/libmimalloc-secure${suffix} $out/lib/libmimalloc${soext} 36 ln -sfv $out/lib/libmimalloc-secure.a $out/lib/libmimalloc.a 37 ln -sfv $out/lib/mimalloc-secure.o $out/lib/mimalloc.o 38 ''); 39 40 outputs = [ "out" "dev" ]; 41 42 meta = with lib; { 43 description = "Compact, fast, general-purpose memory allocator"; 44 homepage = "https://github.com/microsoft/mimalloc"; 45 license = licenses.bsd2; 46 platforms = platforms.unix; 47 maintainers = with maintainers; [ thoughtpolice ]; 48 }; 49}