From mboxrd@z Thu Jan 1 00:00:00 1970 From: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Subject: Re: [PATCH 2/5] gnu: Build lua-5.2 with dynamic library support. Date: Wed, 11 Nov 2015 22:28:42 +0100 Message-ID: <87ziyk9qet.fsf@gnu.org> References: <1447203239.1756982.435572169.304A01DF@webmail.messagingengine.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43777) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zwcwl-0000TY-PF for guix-devel@gnu.org; Wed, 11 Nov 2015 16:28:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zwcwh-0000PM-Gb for guix-devel@gnu.org; Wed, 11 Nov 2015 16:28:51 -0500 In-Reply-To: <1447203239.1756982.435572169.304A01DF@webmail.messagingengine.com> (Leo Famulari's message of "Tue, 10 Nov 2015 19:53:59 -0500") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Leo Famulari Cc: guix-devel@gnu.org Leo Famulari skribis: > On Sun, Nov 8, 2015, at 16:08, Ludovic Court=C3=A8s wrote: >> Leo Famulari skribis: [...] >> How can I test whether this works as expected? I tried this, but I=E2= =80=99m >> unsure whether it=E2=80=99s supposed to load OpenSSL=E2=80=99s libssl.so= directly or >> not: > > There is a Lua library named luasec that provides SSL. Luasec only > supports lua-5.1 except in an alpha release (luasec-0.6). [1] Okay. > I am able to load luasec by telling Lua where to look. I have lua-5.1 > and luasec in my profile: > > $ LUA_PATH=3D~/.guix-profile/share/lua/5.1/\?.lua > LUA_CPATH=3D~/.guix-profile/lib/lua/5.1/\?.so lua -lssl > Lua 5.1.5 Copyright (C) 1994-2012 Lua.org, PUC-Rio >>=20 > ^ That is the Lua prompt, indicating that the Lua interpreter has > successfully imported the SSL libraries. The '?' character is replaced > by the component that Lua is currently searching for. So, if you invoke > `lua -ssl`, the "?.so" in LUA_CPATH is replaced by ssl.so. OK. So in LUA_PATH you need to list the actual .lua files (not just their dirname), and in LUA_CPATH the .so files (not just their dirname), right? >> Besides, it would be nice to get rid of these hard-coded /usr/local in a >> subsequent patch. > > This is related to my next step and I need some advice. > > We need to set LUA_PATH and LUA_CPATH properly in order for programs to > load external Lua libraries. I have been installing Lua libraries into > ${out}/lib/lua/${LUA_VERSION} and ${out}/share/lua/${LUA_VERSION}, so > that they end up at, for example, ~/.guix-profile/lib/lua/5.1/ssl.so [2] It seems we need a =E2=80=98native-search-paths=E2=80=99 thingie here, alon= g these lines: (search-path-specification (variable "LUA_PATH") (files '("share/lua/5.1")) (file-pattern "\\.lua$") (file-type 'regular)) See the =E2=80=98libxml2=E2=80=99 package for an example of how this works. Something similar is needed for =E2=80=98LUA_CPATH=E2=80=99. And then we n= eed to make sure to replace =E2=80=9C5.1=E2=80=9D with the actual version number. That way, when Lua and luasec are in the same profile, =E2=80=98guix package --search-paths=E2=80=99 will suggest the right environment variable settings (and likewise within build environments.) > Nixpkgs makes it all work by setting the paths in wrappers around > programs that need to find Lua libraries. I don't fully understand how > they generate the paths but I get the idea. Some examples: > https://github.com/NixOS/nixpkgs/blob/master/pkgs/servers/xmpp/prosody/de= fault.nix > https://github.com/NixOS/nixpkgs/blob/master/pkgs/applications/video/quvi= /tool.nix > > What do you think? That sounds like the right thing. In Guix this is achieved with =E2=80=98wrap-program=E2=80=99; there are several examples of packages doin= g that. HTH! Ludo=E2=80=99.