unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: raingloom <raingloom@riseup.net>
To: 44662@debbugs.gnu.org
Subject: bug#44662: Lua search paths
Date: Sun, 15 Nov 2020 19:24:41 +0100	[thread overview]
Message-ID: <20201115192441.0af831a5@riseup.net> (raw)

I have a very WIP branch adding search paths to Lua.
https://git.sr.ht/~raingloom/guix-source/tree/raingloom/lua

The problem is that Lua uses a different path format compared to most
packages. Instead of a list of directories, it is a list of path
patterns, each potentially containing a question mark ('?'), which gets
substituted for the module being searched.

For pure Lua modules, this basically means /lib/lua/5.3/?.lua and
/lib/lua/5.3/?/init.lua.
I am not aware of any practical use of paths that do not contain a '?',
so there is a relatively easy solution here:
use the string.gsub function to expand every path component that does
not contain a '?' into two components, the ?.lua and the ?/init.lua one.
This means externally defined components are not expanded, only the
ones defined by Guix.

For C modules, it's a bit trickier, because there is a special
component that looks into loadall.so, which I must admit I'm not
familiar with. As far as I know, popular modules all define their own
shared object file, never a loadall.so.

Also, the path is separated by semicolons, not colons, but I think Guix
can already handle that.

The approaches I see:
- patch loadlib.c in Lua to expand LUA_PATH and LUA_CPATH according to
  the above mentioned heuristics, or
- patch Guix to support paths of this format
- define something like GUIX_LUA_PATH that gets expanded on its own and
  only contains Lua modules defined in Guix, and then gets appended to
  package.path (and do the same for package.path)


Solving this would open up access to the huge variety of Lua modules
and make things like game development in LÖVE much better integrated.
Its users could even use `guix pack` to distribute their games.




             reply	other threads:[~2020-11-15 18:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-15 18:24 raingloom [this message]
2021-03-26  9:28 ` bug#44662: Lua search paths zimoun
2021-03-26 20:29   ` raingloom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201115192441.0af831a5@riseup.net \
    --to=raingloom@riseup.net \
    --cc=44662@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).