summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYappaholic <sav.boyar@gmail.com>2026-05-19 17:47:53 +0300
committerNguyễn Gia Phong <cnx@loang.net>2026-05-26 00:13:16 +0900
commit4d65795173c84329cf1e2f4254150a57c72276bc (patch)
tree0ad5969dcfb031dccb087d23ca3113f74baffacf
parent781c25ada98d70da41c4b2894ddf9216298cf133 (diff)
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 <carlo@zancanaro.id.au> Signed-off-by: Nguyễn Gia Phong <cnx@loang.net>
-rw-r--r--gnu/local.mk1
-rw-r--r--gnu/packages/lua.scm16
-rw-r--r--gnu/packages/patches/lua-5.5-search-paths.patch50
3 files changed, 67 insertions, 0 deletions
diff --git a/gnu/local.mk b/gnu/local.mk
index e766cbeff1a..82a45b613e4 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1880,6 +1880,7 @@ dist_patch_DATA = \
1880 %D%/packages/patches/lua-5.4-pkgconfig.patch \ 1880 %D%/packages/patches/lua-5.4-pkgconfig.patch \
1881 %D%/packages/patches/lua-5.4-liblua-so.patch \ 1881 %D%/packages/patches/lua-5.4-liblua-so.patch \
1882 %D%/packages/patches/lua-5.4-search-paths.patch \ 1882 %D%/packages/patches/lua-5.4-search-paths.patch \
1883 %D%/packages/patches/lua-5.5-search-paths.patch \
1883 %D%/packages/patches/lua-5.x-search-path-helpers.patch \ 1884 %D%/packages/patches/lua-5.x-search-path-helpers.patch \
1884 %D%/packages/patches/lua-lgi-fix-pango.patch \ 1885 %D%/packages/patches/lua-lgi-fix-pango.patch \
1885 %D%/packages/patches/lua-lgi-fix-ref.patch \ 1886 %D%/packages/patches/lua-lgi-fix-ref.patch \
diff --git a/gnu/packages/lua.scm b/gnu/packages/lua.scm
index 0f4ff637951..190b723a02b 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
151for configuration, scripting, and rapid prototyping.") 151for configuration, scripting, and rapid prototyping.")
152 (license license:x11))) 152 (license license:x11)))
153 153
154(define-public lua-5.5
155 (package (inherit lua)
156 (version "5.5.0")
157 (source (origin
158 (method url-fetch)
159 (uri (string-append "https://www.lua.org/ftp/lua-"
160 version ".tar.gz"))
161 (sha256
162 (base32 "0gcbsr00difm2s82pflxg28zcnjka9048lncbfvwl1fhpcmw7k2p"))
163 ;; Note: Some lua-5.4 patches seem to apply without issues
164 (patches (search-patches "lua-5.4-pkgconfig.patch"
165 "lua-5.4-liblua-so.patch"
166 "lua-5.x-search-path-helpers.patch"
167 "lua-5.5-search-paths.patch"))))
168 (native-search-paths (lua-search-paths "5.5"))))
169
154(define-public lua-5.4 170(define-public lua-5.4
155 (package (inherit lua) 171 (package (inherit lua)
156 (version "5.4.8") 172 (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 00000000000..3dcbef563de
--- /dev/null
+++ b/gnu/packages/patches/lua-5.5-search-paths.patch
@@ -0,0 +1,50 @@
1Change Lua to use GUIX_LUA_PATH and GUIX_LUA_CPATH to construct the default
2LUA_PATH and LUA_CPATH, instead of using hard-coded paths that Guix doesn't
3populate.
4
5These paths don't use Lua's usual '?' path wildcard, and thus are compatible
6with Guix's search-paths mechanism.
7
8This patch uses functions defined in lua-5.x-search-path-helpers.patch.
9
10--- a/src/loadlib.c
11+++ b/src/loadlib.c
12@@ -280,7 +280,9 @@
13 if (path == NULL) /* no versioned environment variable? */
14 path = getenv(envname); /* try unversioned name */
15 if (path == NULL || noenv(L)) /* no environment variable? */
16- lua_pushexternalstring(L, dft, strlen(dft), NULL, NULL); /* use default */
17+ /* Copy our constructed default string onto the Lua stack.
18+ * Otherwise the location might be reused for another string and case us problems! */
19+ lua_pushstring(L, dft); /* use default */
20 else if ((dftmark = strstr(path, LUA_PATH_SEP LUA_PATH_SEP)) == NULL)
21 lua_pushstring(L, path); /* nothing to change */
22 else { /* path contains a ";;": insert default path in its place */
23@@ -721,14 +729,25 @@
24 }
25
26
27+#include "./guixpaths.c"
28+
29+
30 LUAMOD_API int luaopen_package (lua_State *L) {
31 luaL_getsubtable(L, LUA_REGISTRYINDEX, CLIBS); /* create CLIBS table */
32 lua_pop(L, 1); /* will not use it now */
33 luaL_newlib(L, pk_funcs); /* create 'package' table */
34 createsearcherstable(L);
35+
36 /* set paths */
37+ /* Calculate default LUA_PATH and LUA_CPATH values from their
38+ corresponding GUIX_ environment variables */
39+ const char* default_path = guix_path(L); // push default_path
40+ const char* default_cpath = guix_cpath(L); // push default_cpath
41+ lua_pushvalue(L, -3); // copy the old head of the stack back to the top
42- setpath(L, "path", LUA_PATH_VAR, LUA_PATH_DEFAULT);
43- setpath(L, "cpath", LUA_CPATH_VAR, LUA_CPATH_DEFAULT);
44+ setpath(L, "path", LUA_PATH_VAR, default_path);
45+ setpath(L, "cpath", LUA_CPATH_VAR, default_cpath);
46+ lua_pop(L, 3); // pop our three working values back off the stack
47+
48 /* store config information */
49 lua_pushliteral(L, LUA_DIRSEP "\n" LUA_PATH_SEP "\n" LUA_PATH_MARK "\n"
50 LUA_EXEC_DIR "\n" LUA_IGMARK "\n");