-
-
Notifications
You must be signed in to change notification settings - Fork 15.5k
lua packages: propagate libs with a setupHook #25846
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The LUA_PATH and LUA_CPATH variables are needed to load libraries. This setupHook exports them to the environment. This allows using installed libraries directly, e.g., nix-instantiate --eval --expr 'with import <nixpkgs> {}; with luaPackages; getLuaCPath cjson' Also fixes some indentation in the lua-modules/generic/default.nix file as it was inconsistent.
Hello! As I mentioned above, there are some failures, but I've checked them on Hydra and it looks like they are already failing. |
} | ||
) | ||
# The function addToSearchPathWithCustomDelimiter breaks with ";" in | ||
# the search path. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why would you use a semi colon instead of a colon?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's the format of LUA_PATH: https://www.lua.org/pil/8.1.html
@FRidh: Do you have any other comments? |
@orbekk no I don't. But then again, I'm also not familiar with Lua. Who is maintaining Lua? Did you cc them? |
Well, lua isn't in a really maintained state in nixpkgs AFAIK. I know about this PR all the time, but I've just been unable to find enough time for it yet. |
@orbekk For what it's worth I have cherry picked this commit, on Linux and the lua interpreter still cannot find the cjson lib, here's a paste: nix@salo:~/badger$ nix-shell -p lua -p luaPackages.cjson --command lua
Let me know if there's anything I can help with, I'd be interested in seeing this merged. |
@richardipsum I get the same behavior, but I'm pretty sure I got this to work when I first made the patch. I don't know why it's not propagating the variables. I'm about to head out on a vacation, so I'll close this PR and continue to work on it later. |
The LUA_PATH and LUA_CPATH variables are needed to load libraries. Export them with a setupHook.
This allows using installed libraries directly, e.g.,
nix-shell -p lua -p luaPackages.cjson --command "lua -e '(require "cjson").encode(1)'"
Also fixes some indentation in the lua-modules/generic/default.nix
file as it was inconsistent.
Motivation for this change
Using lua libraries without having to update LUA_PATH and LUA_CPATH manually.
#25830
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
See below for breakages../result/bin/
)The failures are either broken or not visible on hydra.nixos.org:
luajitPackages.cjson - already broken on hydra
luajitPackages.luaexpat - already broken on hydra
luajitPackages.luazip - already broken on hydra
luajitPackages.lrexlib fail - not on hydra
lua52Packages.lrexlib fail - not on hydra
luajitPackages.mpack fail - disabled on hydra
mudlet fail - disabled on hydra
lua51Packages.lrexlib fail - not on hydra