mirror of
https://git.savannah.gnu.org/git/guix.git
synced 2026-04-07 13:40:36 +02:00
Fixes <https://issues.guix.gnu.org/issue/25425>. * gnu/packages/patches/luajit-search-paths.patch: New file. * gnu/packages/patches/lua-5.1-search-paths.patch: New file. * gnu/packages/patches/lua-5.2-search-paths.patch: New file. * gnu/packages/patches/lua-5.3-search-paths.patch: New file. * gnu/packages/patches/lua-5.4-search-paths.patch: New file. * gnu/packages/patches/lua-5.x-search-path-helpers: New file. * gnu/local.mk (dist_patch_DATA): Register them. * gnu/packages/lua.scm (lua-search-paths): New procedure. (lua) [source]: Apply patches. [native-search-paths]: Define using lua-search-paths. (lua-5.4) [source]: Apply patches. [native-search-paths]: Define using lua-search-paths. (lua-5.2) [source]: Apply patches. [native-search-paths]: Define using lua-search-paths. (lua-5.1) [source]: Apply patches. [native-search-paths]: Define using lua-search-paths. (luajit) [source]: Apply patches. [native-search-paths]: Define GUIX_LUA_PATH and GUIX_LUA_CPATH. Change-Id: I8adc08076e615b3dacc10007eae7c1e9b7d527c0 Signed-off-by: Andreas Enge <andreas@enge.fr>
40 lines
1.5 KiB
Diff
40 lines
1.5 KiB
Diff
Change Lua to use GUIX_LUA_PATH and GUIX_LUA_CPATH to construct the default
|
|
LUA_PATH and LUA_CPATH, instead of using hard-coded paths that Guix doesn't
|
|
populate.
|
|
|
|
These paths don't use Lua's usual '?' path wildcard, and thus are compatible
|
|
with Guix's search-paths mechanism.
|
|
|
|
This patch uses functions defined in lua-5.x-search-path-helpers.patch.
|
|
|
|
--- a/src/loadlib.c
|
|
+++ b/src/loadlib.c
|
|
@@ -624,5 +624,8 @@
|
|
{loader_preload, loader_Lua, loader_C, loader_Croot, NULL};
|
|
|
|
+#include "./guixpaths.c"
|
|
+
|
|
+
|
|
LUALIB_API int luaopen_package (lua_State *L) {
|
|
int i;
|
|
/* create new type _LOADLIB */
|
|
@@ -646,8 +701,16 @@
|
|
lua_rawseti(L, -2, i+1);
|
|
}
|
|
lua_setfield(L, -2, "loaders"); /* put it in field `loaders' */
|
|
- setpath(L, "path", LUA_PATH, LUA_PATH_DEFAULT); /* set field `path' */
|
|
- setpath(L, "cpath", LUA_CPATH, LUA_CPATH_DEFAULT); /* set field `cpath' */
|
|
+
|
|
+ /* Calculate default LUA_PATH and LUA_CPATH values from their
|
|
+ corresponding GUIX_ environment variables */
|
|
+ const char* default_path = guix_path(L); // push default_path
|
|
+ const char* default_cpath = guix_cpath(L); // push default_cpath
|
|
+ lua_pushvalue(L, -3); // copy the old head of the stack back to the top
|
|
+ setpath(L, "path", LUA_PATH, default_path); /* set field `path' */
|
|
+ setpath(L, "cpath", LUA_CPATH, default_cpath); /* set field `cpath' */
|
|
+ lua_pop(L, 3); // pop our three working values back off the stack
|
|
+
|
|
/* store config information */
|
|
lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATHSEP "\n" LUA_PATH_MARK "\n"
|
|
LUA_EXECDIR "\n" LUA_IGMARK);
|