1{ lib
2, stdenv
3, fetchFromGitHub
4, cmake
5, mimalloc
6, ninja
7, openssl
8, zlib
9, testers
10, mold
11}:
12
13stdenv.mkDerivation rec {
14 pname = "mold";
15 version = "1.11.0";
16
17 src = fetchFromGitHub {
18 owner = "rui314";
19 repo = pname;
20 rev = "refs/tags/v${version}";
21 hash = "sha256-dfdrXp05eJALTQnx2F3GxRWKMA+Icj0mRPcb72z7qMw=";
22 };
23
24 nativeBuildInputs = [
25 cmake
26 ninja
27 ];
28
29 buildInputs = [
30 openssl
31 zlib
32 ] ++ lib.optionals (!stdenv.isDarwin) [
33 mimalloc
34 ];
35
36 postPatch = ''
37 sed -i CMakeLists.txt -e '/.*set(DEST\ .*/d'
38 '';
39
40 cmakeFlags = [
41 "-DMOLD_USE_SYSTEM_MIMALLOC:BOOL=ON"
42 ];
43
44 env.NIX_CFLAGS_COMPILE = toString (lib.optionals stdenv.isDarwin [
45 "-faligned-allocation"
46 ]);
47
48 passthru.tests.version = testers.testVersion { package = mold; };
49
50 meta = with lib; {
51 description = "A faster drop-in replacement for existing Unix linkers";
52 longDescription = ''
53 mold is a faster drop-in replacement for existing Unix linkers. It is
54 several times faster than the LLVM lld linker. mold is designed to
55 increase developer productivity by reducing build time, especially in
56 rapid debug-edit-rebuild cycles.
57 '';
58 homepage = "https://github.com/rui314/mold";
59 changelog = "https://github.com/rui314/mold/releases/tag/v${version}";
60 license = licenses.agpl3Plus;
61 maintainers = with maintainers; [ azahi nitsky ];
62 platforms = platforms.unix;
63 };
64}