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";
|
2021-06-29 02:44:03 +02:00
|
|
|
version = "2.0.2";
|
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}";
|
2021-06-29 02:44:03 +02:00
|
|
|
sha256 = "sha256-n4FGld3bq6ZOSLTzXcVlucCGbQ5/eSFbijU0dfBD/T0=";
|
2019-07-04 04:36:26 +02:00
|
|
|
};
|
|
|
|
|
2019-12-03 20:41:28 +01:00
|
|
|
nativeBuildInputs = [ cmake ninja ];
|
2021-06-29 02:51:06 +02:00
|
|
|
cmakeFlags = [ "-DMI_INSTALL_TOPLEVEL=ON" ] ++ 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;
|
2021-06-29 02:51:06 +02:00
|
|
|
suffix = if stdenv.isLinux then "${soext}.${rel}" else ".${rel}${soext}";
|
2020-02-18 03:57:05 +01:00
|
|
|
in ''
|
2021-06-29 02:51:06 +02:00
|
|
|
# first, move headers and cmake files, that's easy
|
|
|
|
mkdir -p $dev/lib
|
|
|
|
mv $out/include $dev/include
|
|
|
|
mv $out/cmake $dev/lib/
|
2019-07-04 04:36:26 +02:00
|
|
|
|
2020-02-18 03:57:05 +01:00
|
|
|
find $out/lib
|
2021-06-29 02:51:06 +02:00
|
|
|
'' + (lib.optionalString secureBuild ''
|
|
|
|
# pretend we're normal mimalloc
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure${suffix} $out/lib/libmimalloc${suffix}
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure${suffix} $out/lib/libmimalloc${soext}
|
|
|
|
ln -sfv $out/lib/libmimalloc-secure.a $out/lib/libmimalloc.a
|
|
|
|
ln -sfv $out/lib/mimalloc-secure.o $out/lib/mimalloc.o
|
|
|
|
'');
|
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 ];
|
|
|
|
};
|
|
|
|
}
|