summaryrefslogtreecommitdiffstats
path: root/pkgs/development/lua-modules/luv/lib.nix
blob: d6e6933d481720eb7f8fed28ec3c61aef40361a9 (plain)
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
{
  lib,
  cmake,
  fixDarwinDylibNames,
  isLuaJIT,
  libuv,
  lua,
  stdenv,
}:

stdenv.mkDerivation {
  pname = "libluv";
  inherit (lua.pkgs.luv) version src meta;

  cmakeFlags = [
    (lib.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
    (lib.cmakeBool "BUILD_STATIC_LIBS" stdenv.hostPlatform.isStatic)
    "-DBUILD_MODULE=OFF"
    "-DWITH_SHARED_LIBUV=ON"
    "-DLUA_BUILD_TYPE=System"
    "-DWITH_LUA_ENGINE=${if isLuaJIT then "LuaJit" else "Lua"}"
  ];

  # to make sure we dont use bundled deps
  prePatch = ''
    rm -rf deps/lua deps/luajit deps/libuv
  '';

  buildInputs = [
    libuv
    lua
  ];

  nativeBuildInputs = [ cmake ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ fixDarwinDylibNames ];

  passthru.tests = {
    # Test luv too
    luv = lua.pkgs.luv.passthru.tests.test;
  };
}