-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
[RFC] get lua support closer to python #33903
Conversation
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.
Some comments while reading through. I have not yet run any tests.
Ideally your update script should also become part of nixpkgs.
pkgs/top-level/lua-packages.nix
Outdated
|
||
#define build lua package function | ||
buildLuaPackage = callPackage ../development/lua-modules/generic lua; | ||
buildLuaPackage = with pkgs.lib; makeOverridable( callPackage ../development/interpreters/lua-5/mk-lua-package.nix { |
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.
Maybe name the file also build-lua-package.nix
for consistency.
@@ -0,0 +1,279 @@ | |||
/* ${GENERATED_NIXFILE} is an auto-generated file -- DO NOT EDIT! */ |
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.
Can you make you generator also to insert comment explaining how to regenerate this file in the header?
license=stdenv.lib.licenses.mit; | ||
description="Event handling through channels"; } | ||
; | ||
src= fetchurl { |
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.
Can you indent with two spaces in your generator and format the code like we do in nixpkgs in general?
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.
I will try to see what i can do in lua but I would rather run some nix prettifier. Any experience with https://github.com/Gabriel439/nixfmt or other advice ?
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.
nixfmt
is probably not production ready. I am not aware of any other tool. Usual people write their tools in the same language as their target language. Then the likelihood is high that people, who are using the generator can also contribute back. Otherwise you can use the alignment feature of the printf
function in bash.
src= fetchurl { | ||
|
||
# url=http://luarocks.org/manifests/teto/coxpcall-scm-1.src.rock; | ||
# sha256="0cz1m32kxi5zx6s69vxdldaafmzqj5wwr69i93abmlz15nx2bqpf"; |
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.
Does your generator also add comments?
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.
sorry xD
|
||
preBuild = '' | ||
cd .. | ||
ls |
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.
Should be removed.
rm -rf $out/share/lua/${lua.luaversion}/cjson/tests | ||
''; | ||
|
||
|
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.
Spurious empty line.
. ${lua}/nix-support/setup-hook | ||
|
||
if [ -L "$out/bin" ]; then | ||
unlink "$out/bin" |
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.
How is the semantic different from using rm
here?
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.
copy pasted from
if [ -L "$out/bin" ]; then |
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.
@FRidh when does the case triggers for python projects?
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.
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.
@teto I don't think we have that problem yet in Lua.
if [ -d "$dir" ]; then | ||
echo "$dir is a folder" | ||
find "$dir" -type f -perm -0100 -print0 | while read -d "" f; do | ||
# Rewrite "#! .../env python" to "#! /nix/store/.../python". |
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.
- # Rewrite "#! .../env python" to "#! /nix/store/.../python".
+ # Rewrite "#! .../env lua" to "#! /nix/store/.../lua".
pkgs/top-level/all-packages.nix
Outdated
@@ -203,6 +203,9 @@ with pkgs; | |||
|
|||
fetchCrate = callPackage ../build-support/rust/fetchcrate.nix { }; | |||
|
|||
gitRepoToName = callPackage ../build-support/fetchgit/gitrepotoname.nix { }; | |||
|
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.
Spurious empty line.
Thanks for the review, I might have uploaded the PR a bit soon but I got a tad excited.
Where should it go ? pkgs/build-support ? (EDIT: found it Right now the PR only supports src.rock format which doesn't exist for many packages. One long term solution could be to have nixos upload the missing src.rock to luarocks.org. nixos could fetch the rockspec and the source separately too. Also I forked luarocks in order to add the |
also when developing, I used to run |
Having a debugging mode and be silent, if no error happens is best practice. |
@teto if you don't want to add the generator to nixpkgs it is up to you. For go ( |
What parts of the rockspec-format does your generators support? https://github.com/luarocks/luarocks/wiki/Rockspec-format |
It supports the strict minimum aka homepage/name/version/url/checksum. I would like to convert licences too as I use a placeholder for now. Anyway I am preparing an update with your input so that package generation/etc can be tested without too much tinkering + some documentation. I'll try to use lua.penlight for pretty printing |
Still a bit messy but at least it becomes usable by others (I think);
|
What I would like to do next is update the lua 5.1/5.3 interpreters to work as 5.2 does. Python copy/pastes the interpreters I believe but in this case I wonder if it's not easier to maintain to just override 5.2 with 5.1 source for instance ? |
I've updated luajit/5.1/5.3 to the new system. lua4 and lua 5.0 don't seem to be used anywhere so I propose to remove them ( According to nox-review (great tool !), I still have problems with "getLuaPath" so I should either reintroduce it or replace it (might require to support luarocks "external_dependencies" for "luaexpat") . My main question at the moment is should I write all the generated packages in one huge "lua-generated-packages.nix" as haskell does and as I currently do or if I should put each package in a separate file and have one file using callPackage on each file (might consume too many inodes ?). |
@teto Sorry, I had a bit of a backlog. Regarding your file questions: If your package generation does not involve manual modifications of packages one file should be fine. For python most libraries are hand written, therefore multiple files are better to handle. |
} | ||
|
||
|
||
declare -A pkg_list=( |
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.
Can you source a file containing pkg_list
externally to separate program and data?
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.
done
I've solved a couple problems on my way towards a successful To make it more consistent with python (and easier to type), I would also like to rename lua5_1 to lua51, lua5_2 to lua52 etc. I wonder if that's ok. |
I should revert some majorVersion changes as I did in lua_step1.
This pull request has been mentioned on Nix community. There might be relevant details there: https://discourse.nixos.org/t/nixos-19-03-feature-freeze/1950/4 |
@teto (shameless plug) as you model this change from Python ecosystem, you probably understand that "overrides" are not very composable. I've been recently exploring the space of using overlays for defining package sets, and here is what I came up with:
And that's it! You can use it Python like:
You can change the packageset via overlays:
which is now composable, as many overlays can easily add/override packages. Disclaimer: I've done this with postgresql, but it is not yet approved/reviewed/merged (https://github.com/NixOS/nixpkgs/pull/54319/files) |
@danbst thanks for the heads up/advice. The thread has become kinda messy but in fact while I started copying the python's approach, I ended up with the haskell way (well a mix of both). I've started this more than a year ago and would like to get the behavior merged (some things can be improved later certainly). |
First step towards more automation similar to the haskell backend. Follow up of NixOS#33903
* lua: add withPackages function First step towards more automation similar to the haskell backend. Follow up of #33903
As far as I can tell this is superseded by smaller PRs that implement these changes piecewise? Can we close it? |
the most crucial part (luawithPackages) which was causing me pain when rebasing was merged so I close this (also because the page takes too long to load). Yet I like the idea of tracking some unmerged changes so I will create a new one. |
Motivation for this change
My motivation is to be able to run neovim tests/plugins which rely on lua.
This PR can import a whitelist of packages (rockspec and src.rock) from luarocks automatically into nixpkgs.
Things done
Delegate lua packages handling to luarocks, similar to what python can do with pipy.
i have forked luarocks to generate a list of nix derivations from luarocks packages
https://github.com/teto/luarocks/tree/nix (needs cjson) and then run with
luarocks nix [--server=SERVER] PKG_NAME
Right now, buildLuarocksPackage works with luarocks rocks (*.src.rock files = a zip archive with a rockspec describing the package + the source code) and rockspecs.
Possibie improvements
external_deps_dirs = {}
(https://github.com/luarocks/luarocks/wiki/Paths-and-external-dependencies)Here is an upstreaming roadmap:
build-use-sandbox
innix.conf
on non-NixOS)nix-shell -p nox --run "nox-review wip"
./result/bin/
)