at 25.11-pre 95 lines 2.4 kB view raw
1{ 2 lib, 3 buildLuarocksPackage, 4 cmake, 5 fetchFromGitHub, 6 libuv, 7 lua, 8 luaOlder, 9 nix-update-script, 10 runCommand, 11}: 12 13buildLuarocksPackage rec { 14 pname = "luv"; 15 version = "1.50.0-1"; 16 17 src = fetchFromGitHub { 18 owner = "luvit"; 19 repo = "luv"; 20 rev = version; 21 # Need deps/lua-compat-5.3 only 22 fetchSubmodules = true; 23 hash = "sha256-PS3+qpELpX0tr7UqrlnE4NYScJb50j+9J4fbH9CTr/s="; 24 }; 25 26 # to make sure we dont use bundled deps 27 prePatch = '' 28 rm -rf deps/lua deps/luajit deps/libuv 29 ''; 30 31 buildInputs = [ libuv ]; 32 nativeBuildInputs = [ cmake ]; 33 34 # Need to specify WITH_SHARED_LIBUV=ON cmake flag, but 35 # Luarocks doesn't take cmake variables from luarocks config. 36 # Need to specify it in rockspec. See https://github.com/luarocks/luarocks/issues/1160. 37 knownRockspec = runCommand "luv-${version}.rockspec" { } '' 38 patch ${src}/luv-scm-0.rockspec -o - > $out <<'EOF' 39 --- a/luv-scm-0.rockspec 40 +++ b/luv-scm-0.rockspec 41 @@ -1,5 +1,5 @@ 42 package = "luv" 43 -version = "scm-0" 44 +version = "${version}" 45 source = { 46 url = 'git://github.com/luvit/luv.git' 47 } 48 @@ -24,6 +24,7 @@ 49 build = 50 type = 'cmake', 51 variables = { 52 + WITH_SHARED_LIBUV="ON", 53 CMAKE_C_FLAGS="$(CFLAGS)", 54 CMAKE_MODULE_LINKER_FLAGS="$(LIBFLAG)", 55 LUA_LIBDIR="$(LUA_LIBDIR)", 56 EOF 57 ''; 58 59 doInstallCheck = true; 60 installCheckPhase = '' 61 rm tests/test-{dns,thread,tty}.lua 62 luarocks test 63 ''; 64 65 disabled = luaOlder "5.1"; 66 67 passthru = { 68 tests.test = 69 runCommand "luv-${version}-test" 70 { 71 nativeBuildInputs = [ (lua.withPackages (ps: [ ps.luv ])) ]; 72 } 73 '' 74 lua <<EOF 75 local uv = require("luv") 76 assert(uv.fs_mkdir(assert(uv.os_getenv("out")), 493)) 77 print(uv.version_string()) 78 EOF 79 ''; 80 81 updateScript = nix-update-script { }; 82 }; 83 84 meta = { 85 homepage = "https://github.com/luvit/luv"; 86 description = "Bare libuv bindings for lua"; 87 longDescription = '' 88 This library makes libuv available to lua scripts. It was made for the luvit 89 project but should usable from nearly any lua project. 90 ''; 91 license = lib.licenses.asl20; 92 maintainers = with lib.maintainers; [ stasjok ]; 93 platforms = lua.meta.platforms; 94 }; 95}