From f9bcddfaaa50e43a9f027ac63d86383142e40015 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C3=ADas=20Lang?= Date: Fri, 29 May 2020 01:06:03 -0300 Subject: [PATCH] mpv: don't use generated luasocket The luarocks version of luasocket crashes if the host program has symbols with the same name as luasocket, such as "socket_create". This change makes mpv use a custom luasocket derivation that isn't built from luarocks. This new derivation has the same code as "luaPackages.luasocket" before commit 274715cbc355e9d50e07a2f60a65a183f7d9855d. Closes #88584 --- pkgs/applications/video/mpv/default.nix | 2 +- pkgs/top-level/lua-packages.nix | 39 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/pkgs/applications/video/mpv/default.nix b/pkgs/applications/video/mpv/default.nix index 9cb39d6814015..5c3d2a1518154 100644 --- a/pkgs/applications/video/mpv/default.nix +++ b/pkgs/applications/video/mpv/default.nix @@ -93,7 +93,7 @@ assert xvSupport -> x11Support && available libXv; assert zimgSupport -> available zimg; let - luaEnv = lua.withPackages (ps: with ps; [ luasocket ]); + luaEnv = lua.withPackages (ps: with ps; [ luasocket-git ]); in stdenv.mkDerivation rec { pname = "mpv"; diff --git a/pkgs/top-level/lua-packages.nix b/pkgs/top-level/lua-packages.nix index 7cf47c26c6fc4..de48819ffcdd8 100644 --- a/pkgs/top-level/lua-packages.nix +++ b/pkgs/top-level/lua-packages.nix @@ -99,6 +99,45 @@ with self; { luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; + luasocket-git = buildLuaPackage rec { + name = "socket-${version}"; + version = "3.0-rc1"; + + src = fetchFromGitHub { + owner = "diegonehab"; + repo = "luasocket"; + rev = "v${version}"; + sha256 = "1chs7z7a3i3lck4x7rz60ziwbf793gw169hpjdfca8y4yf1hzsxk"; + }; + + patchPhase = stdenv.lib.optionalString stdenv.isDarwin '' + substituteInPlace src/makefile \ + --replace 10.3 10.5 + ''; + + preBuild = '' + makeFlagsArray=( + LUAV=${lua.luaversion} + PLAT=${platformString} + CC=''${CC} + LD=''${CC} + prefix=$out + ); + ''; + + doCheck = false; # fails to find itself + + installTargets = [ "install" "install-unix" ]; + + meta = with stdenv.lib; { + description = "Network support for Lua"; + homepage = "http://w3.impa.br/~diego/software/luasocket/"; + license = licenses.mit; + maintainers = with maintainers; [ ]; + platforms = with platforms; darwin ++ linux ++ freebsd ++ illumos; + }; + }; + luxio = buildLuaPackage rec { name = "luxio-${version}"; version = "13";