[Nix-dev] Lua modules support

François Perrad francois.perrad at gadz.org
Tue Mar 30 12:04:33 CEST 2010


Hi List,

I try to add the support for Lua modules.
I fail with postInstall & fixupPhase.

First, there are no standard way to build a Lua module (like with Perl
or Python).
The interpreter Lua uses 2 environments variables :
 - LUA_PATH for Lua files
 - LUA_CPATH for shared libraries
There format is different of PATH or PYTHONPATH one.
See http://www.lua.org/manual/5.1/manual.html#pdf-package.loaders,
http://www.lua.org/manual/5.1/manual.html#pdf-package.cpath,
http://www.lua.org/manual/5.1/manual.html#pdf-package.path.

The interpreter Lua has no option -I
But Lua script could be wrapped like following :

#! /nix/store/...lua-5.1.4/bin/lua
package.cpath = "... content of $LUA_CPATH ..."
package.path = " ... content of $LUA_PATH ..."
-- end of wrapping

I start with small modules which represent various cases :
- Coat : pure Lua modules, depends of TestMore, has a script bin/coat2uml
- lfs : native extension (without test)
- lpeg : native extension
- socket : native extensions + Lua modules (without out)
- random : native extension
- TestLongString : pure Lua module, depends of TestMore
- TestMore : pure Lua module

after install, it's easy to check paths with the option -l, for example :
 $ lua -l lfs
 $ lua -l Test.More

François Perrad
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-first-Lua-modules.patch
Type: text/x-diff
Size: 9767 bytes
Desc: not available
Url : http://lists.science.uu.nl/pipermail/nix-dev/attachments/20100330/898e78a6/attachment.bin 


More information about the nix-dev mailing list