summary refs log tree commit diff
path: root/pkgs/development/tools/mold/default.nix
blob: 1d4a64d4467e7bd0fc0686b27e1c0970e5092afe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
{ lib
, stdenv
, fetchFromGitHub
, cmake
, mimalloc
, ninja
, openssl
, zlib
, testers
, mold
}:

stdenv.mkDerivation rec {
  pname = "mold";
  version = "1.4.2";

  src = fetchFromGitHub {
    owner = "rui314";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-omi4vx8KDpgZ/y3MvE5c/9MxSLXIA4IHJAMue3XpfD8=";
  };

  nativeBuildInputs = [ cmake ninja ];

  buildInputs = [ openssl zlib ]
    ++ lib.optionals (!stdenv.isDarwin) [ mimalloc ];

  postPatch = ''
    sed -i CMakeLists.txt -e '/.*set(DEST\ .*/d'
  '';

  cmakeFlags = [ "-DMOLD_USE_SYSTEM_MIMALLOC:BOOL=ON" ];

  NIX_CFLAGS_COMPILE = lib.optionals stdenv.isDarwin [ "-faligned-allocation" ];

  passthru.tests.version = testers.testVersion { package = mold; };

  meta = with lib; {
    description = "A faster drop-in replacement for existing Unix linkers";
    longDescription = ''
      mold is a faster drop-in replacement for existing Unix linkers. It is
      several times faster than the LLVM lld linker. mold is designed to
      increase developer productivity by reducing build time, especially in
      rapid debug-edit-rebuild cycles.
    '';
    homepage = "https://github.com/rui314/mold";
    license = licenses.agpl3Plus;
    maintainers = with maintainers; [ azahi nitsky ];
    platforms = platforms.unix;
    # https://github.com/NixOS/nixpkgs/pull/189712#issuecomment-1237791234
    broken = (stdenv.isLinux && stdenv.isAarch64);
  };
}