guix_mirror_bot pushed a commit to branch master
in repository guix.
commit 4d65795173c84329cf1e2f4254150a57c72276bc
Author: Yappaholic <[email protected]>
AuthorDate: Tue May 19 17:47:53 2026 +0300
gnu: Add lua-5.5.
* gnu/packages/lua.scm (lua-5.5): New variable.
Merges: https://codeberg.org/guix/guix/pulls/8515
Reviewed-by: Carlo Zancanaro <[email protected]>
Signed-off-by: Nguyễn Gia Phong <[email protected]>
---
gnu/local.mk | 1 +
gnu/packages/lua.scm | 16 ++++++++
gnu/packages/patches/lua-5.5-search-paths.patch | 50 +++++++++++++++++++++++++
3 files changed, 67 insertions(+)
diff --git a/gnu/local.mk b/gnu/local.mk
index e766cbeff1..82a45b613e 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1880,6 +1880,7 @@ dist_patch_DATA =
\
%D%/packages/patches/lua-5.4-pkgconfig.patch \
%D%/packages/patches/lua-5.4-liblua-so.patch \
%D%/packages/patches/lua-5.4-search-paths.patch \
+ %D%/packages/patches/lua-5.5-search-paths.patch \
%D%/packages/patches/lua-5.x-search-path-helpers.patch \
%D%/packages/patches/lua-lgi-fix-pango.patch \
%D%/packages/patches/lua-lgi-fix-ref.patch \
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 0f4ff63795..190b723a02 100644
--- a/gnu/packages/lua.scm
+++ b/gnu/packages/lua.scm
@@ -151,6 +151,22 @@ automatic memory management with incremental garbage
collection, making it ideal
for configuration, scripting, and rapid prototyping.")
(license license:x11)))
+(define-public lua-5.5
+ (package (inherit lua)
+ (version "5.5.0")
+ (source (origin
+ (method url-fetch)
+ (uri (string-append "https://www.lua.org/ftp/lua-"
+ version ".tar.gz"))
+ (sha256
+ (base32
"0gcbsr00difm2s82pflxg28zcnjka9048lncbfvwl1fhpcmw7k2p"))
+ ;; Note: Some lua-5.4 patches seem to apply without issues
+ (patches (search-patches "lua-5.4-pkgconfig.patch"
+ "lua-5.4-liblua-so.patch"
+
"lua-5.x-search-path-helpers.patch"
+ "lua-5.5-search-paths.patch"))))
+ (native-search-paths (lua-search-paths "5.5"))))
+
(define-public lua-5.4
(package (inherit lua)
(version "5.4.8")
diff --git a/gnu/packages/patches/lua-5.5-search-paths.patch
b/gnu/packages/patches/lua-5.5-search-paths.patch
new file mode 100644
index 0000000000..3dcbef563d
--- /dev/null
+++ b/gnu/packages/patches/lua-5.5-search-paths.patch
@@ -0,0 +1,50 @@
+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
+@@ -280,7 +280,9 @@
+ if (path == NULL) /* no versioned environment variable? */
+ path = getenv(envname); /* try unversioned name */
+ if (path == NULL || noenv(L)) /* no environment variable? */
+- lua_pushexternalstring(L, dft, strlen(dft), NULL, NULL); /* use default
*/
++ /* Copy our constructed default string onto the Lua stack.
++ * Otherwise the location might be reused for another string and case us
problems! */
++ lua_pushstring(L, dft); /* use default */
+ else if ((dftmark = strstr(path, LUA_PATH_SEP LUA_PATH_SEP)) == NULL)
+ lua_pushstring(L, path); /* nothing to change */
+ else { /* path contains a ";;": insert default path in its place */
+@@ -721,14 +729,25 @@
+ }
+
+
++#include "./guixpaths.c"
++
++
+ LUAMOD_API int luaopen_package (lua_State *L) {
+ luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); /* create CLIBS table */
+ lua_pop(L, 1); /* will not use it now */
+ luaL_newlib(L, pk_funcs); /* create 'package' table */
+ createsearcherstable(L);
++
+ /* set paths */
++ /* 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_VAR, LUA_PATH_DEFAULT);
+- setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
++ setpath(L, "path", LUA_PATH_VAR, default_path);
++ setpath(L, "cpath", LUA_CPATH_VAR, default_cpath);
++ lua_pop(L, 3); // pop our three working values back off the stack
++
+ /* store config information */
+ lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
+ LUA_EXEC_DIR "\n" LUA_IGMARK "\n");