2021-01-21 18:00:13 +01:00
|
|
|
{ lib, stdenv, fetchFromGitHub, cmake, ninja
|
2019-12-07 01:16:56 +01:00
|
|
|
, secureBuild ? false
|
2019-07-04 04:36:26 +02:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
soext = stdenv.hostPlatform.extensions.sharedLibrary;
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
2019-12-03 20:41:28 +01:00
|
|
|
pname = "mimalloc";
|
2020-11-03 15:39:31 +01:00
|
|
|
version = "1.6.7";
|
2019-07-04 04:36:26 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "microsoft";
|
2019-12-03 20:41:28 +01:00
|
|
|
repo = pname;
|
2020-02-18 03:57:05 +01:00
|
|
|
rev = "v${version}";
|
2020-11-03 15:39:31 +01:00
|
|
|
sha256 = "1ymffs3ixc4vkhpr09ph6xhyknm2cx8ij8j5l70cq6119mwilnwa";
|
2019-07-04 04:36:26 +02:00
|
|
|
};
|
|
|
|
|
2019-12-03 20:41:28 +01:00
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
2021-01-21 18:00:13 +01:00
|
|
|
cmakeFlags = lib.optional secureBuild [ "-DMI_SECURE=ON" ];
|
2019-07-04 04:36:26 +02:00
|
|
|
|
2020-02-18 03:57:05 +01:00
|
|
|
postInstall = let
|
2021-01-21 18:00:13 +01:00
|
|
|
rel = lib.versions.majorMinor version;
|
2020-02-18 03:57:05 +01:00
|
|
|
in ''
|
2019-12-03 20:41:28 +01:00
|
|
|
# first, install headers, that's easy
|
2019-07-04 04:36:26 +02:00
|
|
|
mkdir -p $dev
|
|
|
|
mv $out/lib/*/include $dev/include
|
|
|
|
|
2019-12-07 01:16:56 +01:00
|
|
|
# move .a and .o files into place
|
2020-02-18 03:57:05 +01: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 04:36:26 +02:00
|
|
|
|
2019-12-07 01:16:56 +01:00
|
|
|
'' + (if secureBuild then ''
|
2020-02-18 03:57:05 +01: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 01:16:56 +01:00
|
|
|
'' else ''
|
2020-02-18 03:57:05 +01: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 01:16:56 +01:00
|
|
|
'') + ''
|
2019-12-03 20:41:28 +01:00
|
|
|
# remote duplicate dir. FIXME: try to fix the .cmake file distribution
|
|
|
|
# so we can re-use it for dependencies...
|
2020-02-18 03:57:05 +01:00
|
|
|
rm -rf $out/lib/mimalloc-${rel}
|
2019-07-04 04:36:26 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
outputs = [ "out" "dev" ];
|
|
|
|
|
2021-01-21 18:00:13 +01:00
|
|
|
meta = with lib; {
|
2019-07-04 04:36:26 +02: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 03:57:05 +01:00
|
|
|
badPlatforms = platforms.darwin;
|
2019-07-04 04:36:26 +02:00
|
|
|
};
|
|
|
|
}
|