2021-02-05 17:12:51 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, ninja
|
2020-04-24 23:36:52 +00:00
|
|
|
, secureBuild ? false
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
soext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "mimalloc";
|
2021-03-23 19:22:30 +00:00
|
|
|
version = "2.0.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "microsoft";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2021-03-23 19:22:30 +00:00
|
|
|
sha256 = "sha256-BMDCreY41CxJaPo9BdSRZlqh/YjtPC9aI/Zxt501e+0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
2021-02-05 17:12:51 +00:00
|
|
|
cmakeFlags = lib.optional secureBuild [ "-DMI_SECURE=ON" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = let
|
2021-02-05 17:12:51 +00:00
|
|
|
rel = lib.versions.majorMinor version;
|
2020-04-24 23:36:52 +00:00
|
|
|
in ''
|
|
|
|
# first, install headers, that's easy
|
|
|
|
mkdir -p $dev
|
|
|
|
mv $out/lib/*/include $dev/include
|
|
|
|
|
|
|
|
# move .a and .o files into place
|
|
|
|
find $out/lib
|
|
|
|
mv $out/lib/mimalloc-${rel}/libmimalloc*.a $out/lib/libmimalloc.a
|
|
|
|
mv $out/lib/mimalloc-${rel}/mimalloc*.o $out/lib/mimalloc.o
|
|
|
|
|
|
|
|
'' + (if secureBuild then ''
|
|
|
|
mv $out/lib/mimalloc-${rel}/libmimalloc-secure${soext}.${rel} $out/lib/libmimalloc-secure${soext}.${rel}
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure${soext}.${rel} $out/lib/libmimalloc-secure${soext}
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure${soext}.${rel} $out/lib/libmimalloc${soext}
|
|
|
|
'' else ''
|
|
|
|
mv $out/lib/mimalloc-${rel}/libmimalloc${soext}.${rel} $out/lib/libmimalloc${soext}.${rel}
|
|
|
|
ln -sfv $out/lib/libmimalloc${soext}.${rel} $out/lib/libmimalloc${soext}
|
|
|
|
'') + ''
|
|
|
|
# remote duplicate dir. FIXME: try to fix the .cmake file distribution
|
|
|
|
# so we can re-use it for dependencies...
|
|
|
|
rm -rf $out/lib/mimalloc-${rel}
|
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Compact, fast, general-purpose memory allocator";
|
|
|
|
homepage = "https://github.com/microsoft/mimalloc";
|
|
|
|
license = licenses.bsd2;
|
|
|
|
platforms = platforms.unix;
|
|
|
|
maintainers = with maintainers; [ thoughtpolice ];
|
|
|
|
badPlatforms = platforms.darwin;
|
|
|
|
};
|
|
|
|
}
|