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