| 1 | Change Lua to use GUIX_LUA_PATH and GUIX_LUA_CPATH to construct the default
|
| 2 | LUA_PATH and LUA_CPATH, instead of using hard-coded paths that Guix doesn't
|
| 3 | populate.
|
| 4 |
|
| 5 | These paths don't use Lua's usual '?' path wildcard, and thus are compatible
|
| 6 | with Guix's search-paths mechanism.
|
| 7 |
|
| 8 | This patch uses functions defined in lua-5.x-search-path-helpers.patch.
|
| 9 |
|
| 10 | |
| 11 | |
| 12 | @@ -624,5 +624,8 @@
|
| 13 | {loader_preload, loader_Lua, loader_C, loader_Croot, NULL};
|
| 14 |
|
| 15 | +#include "./guixpaths.c"
|
| 16 | +
|
| 17 | +
|
| 18 | LUALIB_API int luaopen_package (lua_State *L) {
|
| 19 | int i;
|
| 20 | /* create new type _LOADLIB */
|
| 21 | @@ -646,8 +701,16 @@
|
| 22 | lua_rawseti(L, -2, i+1);
|
| 23 | }
|
| 24 | lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */
|
| 25 | - setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */
|
| 26 | - setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
|
| 27 | +
|
| 28 | + /* Calculate default LUA_PATH and LUA_CPATH values from their
|
| 29 | + corresponding GUIX_ environment variables */
|
| 30 | + const char* default_path = guix_path(L); // push default_path
|
| 31 | + const char* default_cpath = guix_cpath(L); // push default_cpath
|
| 32 | + lua_pushvalue(L, -3); // copy the old head of the stack back to the top
|
| 33 | + setpath(L, "path", LUA_PATH, default_path); /* set field `path' */
|
| 34 | + setpath(L, "cpath", LUA_CPATH, default_cpath); /* set field `cpath' */
|
| 35 | + lua_pop(L, 3); // pop our three working values back off the stack
|
| 36 | +
|
| 37 | /* store config information */
|
| 38 | lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
|
| 39 | LUA_EXECDIR "\n" LUA_IGMARK);
|