When installing a lua package that depends on luarocks, luarocks was not
capable of recognizing the luarocks module: https://github.com/NixOS/nixpkgs/issues/316009 .
As explained here https://github.com/luarocks/luarocks/issues/1659,
luarocks needs a manifest to recognize the package.
I first attempted to generate a manifest with `luarocks-admin
make-manifest` on our current manual luarocks derivation but this ended
up being too hackish as the `make-manifest` requires a .rockspec or
.rock to work, which we had not.
It seemed simpled to just rename the current manual luarocks derivation to luarocks_bootstrap
in order to break cyclic dependencies in buildLuarocksPackage and add a
generated luarocks derivation. Previously it was impossible to test
luarocks because of the cyclic dependency but we will now be able to
test the generated derivation.
which contains lua shell utilities that can be reused during the
creation of an environment.
Makes sense because the generation of LUA_PATH is a bit different than
other ecosystems.
lua.withPackages only brings packages that have passthru.luaModule, which was not the case of luarocks (because it's built differently than other lua packages). We call toLuaModule on luarocks so that it is brought in a lua.withPackages call
remove the inherit line did not work
fixes mpv for example
nix-repl> pkgsCross.aarch64-multiplatform.lua.withPackages (ps: with ps; [ luasocket ])
error: attribute 'runtimeShell' missing
at /home/artturin/nixgits/my-nixpkgs/pkgs/top-level/all-packages.nix:849:17:
848| substitutions = {
849| shell = targetPackages.runtimeShell;
| ^
850| passthru.tests = tests.makeWrapper;
… while evaluating the attribute 'shell' of the derivation 'hook'
at /home/artturin/nixgits/my-nixpkgs/pkgs/stdenv/generic/make-derivation.nix:270:7:
269| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
270| name =
| ^
271| let
… while evaluating 'optionalString'
at /home/artturin/nixgits/my-nixpkgs/lib/strings.nix:203:5:
202| # String to return if condition is true
203| string: if cond then string else "";
| ^
204|
… from call site
at /home/artturin/nixgits/my-nixpkgs/pkgs/build-support/trivial-builders.nix:536:12:
535| cp ${script} $out/nix-support/setup-hook
536| '' + lib.optionalString (deps != []) ''
| ^
537| printWords ${toString deps} > $out/nix-support/propagated-build-inputs
… while evaluating the attribute 'buildCommand' of the derivation 'hook'
at /home/artturin/nixgits/my-nixpkgs/pkgs/stdenv/generic/make-derivation.nix:270:7:
269| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
270| name =
| ^
271| let
… while evaluating anonymous lambda
at /home/artturin/nixgits/my-nixpkgs/lib/lists.nix:646:25:
645| */
646| unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
| ^
647|
… from call site
at /home/artturin/nixgits/my-nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix:105:27:
104| # example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
105| externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (
| ^
106| luarocksDrv.nativeBuildInputs ++ luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs)
… while evaluating 'generateLuarocksConfig'
at /home/artturin/nixgits/my-nixpkgs/pkgs/development/lua-modules/lib.nix:83:28:
82| */
83| generateLuarocksConfig = {
| ^
84| externalDeps
… from call site
at /home/artturin/nixgits/my-nixpkgs/pkgs/development/interpreters/lua-5/build-lua-package.nix:85:23:
84| luarocks_content = let
85| generatedConfig = lua.pkgs.lib.generateLuarocksConfig {
| ^
86| externalDeps = externalDeps ++ externalDepsGenerated;
… while evaluating the attribute 'configurePhase' of the derivation 'lua5.2-luasocket-3.0.0-1-aarch64-unknown-linux-gnu'
at /home/artturin/nixgits/my-nixpkgs/pkgs/stdenv/generic/make-derivation.nix:270:7:
269| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
270| name =
| ^
271| let
… while evaluating anonymous lambda
at /home/artturin/nixgits/my-nixpkgs/lib/lists.nix:646:25:
645| */
646| unique = foldl' (acc: e: if elem e acc then acc else acc ++ [ e ]) [];
| ^
647|
… from call site
at /home/artturin/nixgits/my-nixpkgs/pkgs/development/lua-modules/lib.nix:5:6:
4| modules = filter hasLuaModule drvs;
5| in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules));
| ^
6| # Check whether a derivation provides a lua module.
… while evaluating 'requiredLuaModules'
at /home/artturin/nixgits/my-nixpkgs/pkgs/development/lua-modules/lib.nix:3:24:
2| let
3| requiredLuaModules = drvs: with lib; let
| ^
4| modules = filter hasLuaModule drvs;
… from call site
at /home/artturin/nixgits/my-nixpkgs/pkgs/development/interpreters/lua-5/wrapper.nix:13:14:
12| env = let
13| paths = requiredLuaModules (extraLibs ++ [ lua ] );
| ^
14| in buildEnv {
… while evaluating the attribute 'passAsFile'
at /home/artturin/nixgits/my-nixpkgs/pkgs/build-support/buildenv/default.nix:77:5:
76| # XXX: The size is somewhat arbitrary
77| passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
| ^
78| }
… while evaluating the attribute 'passAsFile' of the derivation 'lua-aarch64-unknown-linux-gnu-5.2.4-env'
at /home/artturin/nixgits/my-nixpkgs/pkgs/stdenv/generic/make-derivation.nix:270:7:
269| // (lib.optionalAttrs (attrs ? name || (attrs ? pname && attrs ? version)) {
270| name =
| ^
271| let
Neovim plugins are now more often than not written in lua.
One advantage of the lua ecosystem over vim's is the existence of
luarocks and the rockspec format, which allows to specify a package
dependencies formally.
I would like more neovim plugins to have a formal description,
"rockspec" being the current candidate.
This MR allows to use nix lua packages as neovim plugins, so as to enjoy
every benefit that rockspecs bring:
- dependdency discovery
- ability to run test suite
- luarocks versioning
- rockspec metadata
the vim update.py script will check if an attribute with the vim plugin
pname exists in lua51Packages. If it does, it uses
buildNeovimPluginFrom2Nix on it, which modifies the luarocks config to
do an almost flat install (luarocks will install the package in the lua
folder instead of share/5.1/lua etc).
It also calls toVimPlugin on it to get all the vim plugin niceties.
The list of packages that could benefit from this is available at
https://luarocks.org/labels/neovim
but I hope it grows.
luaLib.luaPathList is a list and not a function anymore which results in
the following error:
error: attempt to call something which is not a function but a list
at /nix/store/v94vpi9na0flcnhh9gbmzcvbgfzqm10g-source/pkgs/top-level/lua-packages.nix:50:35:
49| getLuaPath = drv: getPath drv (luaLib.luaPathList lua.luaversion) ;
50| getLuaCPath = drv: getPath drv (luaLib.luaCPathList lua.luaversion) ;
| ^
51|
- moved lua hooks to a specific folder as I foresee to add more
- moved generateLuarocksConfig to lib
- fix getLuaPath
- removed the useless rockspecDir
Goal is to improve separation between packages and utilities.
Can help with autocompletion/navigate nixpkgs faster.
Also it will help standardize how LUA_PATH is exported across packages,
so that one can more easily make lua changes across nixpkgs (for
instance changing where lua modules are installed).
This commit shows how to convert luarocks packages into (neo)vim ones.
The advantage for neovim lua plugins to register their rockspec (aka
package definition) is that the plugin can express its dependencies and
a few metadata through it.
continuation of #109595
pkgconfig was aliased in 2018, however, it remained in
all-packages.nix due to its wide usage. This cleans
up the remaining references to pkgs.pkgsconfig and
moves the entry to aliases.nix.
python3Packages.pkgconfig remained unchanged because
it's the canonical name of the upstream package
on pypi.
- Lua packages now consistently use LUA_PATH/LUA_CPATH rather than a mix
of those and NIX_LUA_PATH/NIX_LUA_CPATH
- Lua libraries are now consistently only added to the search path
variables if:
1) The library actually has a corresponding directory to search
2) The library is not already present in the search path
This should help prevent the search paths from growing overly large
- Fixed bugs in some path helpers
- Changed the affected shell script indentation to 2 spaces; nixpkgs
shell scripts are inconsistently split between 2 and 4 space
indentation, but 2 matches better with the Nix expressions, so IMO it
makes more sense