Merge pull request #134336 from teto/luarocks-rockspec-relpath

lua updater: support in-repo rockspecs
This commit is contained in:
Matthieu Coudron 2021-09-01 10:31:14 +02:00 committed by GitHub
commit b4e6ec08f4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 1193 additions and 757 deletions

View file

@ -1,89 +1,86 @@
name,server,version,luaversion,maintainers
alt-getopt,,,,arobyn
ansicolors,,,,
bit32,,5.3.0-1,lua5_1,lblasc
argparse,,,,
basexx,,,,
binaryheap,,,,vcunat
busted,,,,
cassowary,,,,marsam alerque
compat53,,0.7-1,,vcunat
cosmo,,,,marsam
coxpcall,,1.17.0-1,,
cqueues,,,,vcunat
cyrussasl,,,,
digestif,,0.2-1,lua5_3,
dkjson,,,,
fifo,,,,
gitsigns.nvim,,,lua5_1,
http,,0.3-0,,vcunat
inspect,,,,
ldbus,http://luarocks.org/dev,,,
ldoc,,,,
lgi,,,,
linenoise,,,,
ljsyscall,,,lua5_1,lblasc
lpeg,,,,vyp
lpeg_patterns,,,,
lpeglabel,,,,
lpty,,,,
lrexlib-gnu,,,,
lrexlib-pcre,,,,vyp
lrexlib-posix,,,,
ltermbox,,,,
lua-cjson,,,,
lua-cmsgpack,,,,
lua-iconv,,,,
lua-lsp,http://luarocks.org/dev,,,
lua-messagepack,,,,
lua-resty-http,,,,
lua-resty-jwt,,,,
lua-resty-openidc,,,,
lua-resty-openssl,,,,
lua-resty-session,,,,
lua-term,,,,
lua-toml,,,,
lua-zlib,,,,koral
lua_cliargs,,,,
luabitop,,,,
luacheck,,,,
luacov,,,,
luadbi,,,,
luadbi-mysql,,,,
luadbi-postgresql,,,,
luadbi-sqlite3,,,,
luadoc,,,,
luaepnf,,,,
luaevent,,,,
luaexpat,,1.3.0-1,,arobyn flosse
luaffi,http://luarocks.org/dev,,,
luafilesystem,,1.7.0-2,,flosse
lualogging,,,,
luaossl,,,lua5_1,
luaposix,,34.1.1-1,,vyp lblasc
luarepl,,,,
luasec,,,,flosse
luasocket,,,,
luasql-sqlite3,,,,vyp
luassert,,,,
luasystem,,,,
luautf8,,,,pstn
luazip,,,,
lua-yajl,,,,pstn
luuid,,,,
luv,,1.30.0-0,,
lyaml,,,,lblasc
markdown,,,,
mediator_lua,,,,
mpack,,,,
moonscript,,,,arobyn
nvim-client,,,,
penlight,,,,
plenary.nvim,,,lua5_1,
rapidjson,,,,
readline,,,,
say,,,,
std._debug,,,,
std.normalize,,,,
stdlib,,,,vyp
vstruct,,,,
name,src,ref,server,version,luaversion,maintainers
alt-getopt,,,,,,arobyn
bit32,,,,5.3.0-1,lua5_1,lblasc
argparse,https://github.com/luarocks/argparse.git,,,,,
basexx,https://github.com/teto/basexx.git,,,,,
binaryheap,https://github.com/Tieske/binaryheap.lua,,,,,vcunat
busted,,,,,,
cassowary,,,,,,marsam alerque
compat53,,,,0.7-1,,vcunat
cosmo,,,,,,marsam
coxpcall,,,,1.17.0-1,,
cqueues,,,,,,vcunat
cyrussasl,https://github.com/JorjBauer/lua-cyrussasl.git,,,,,
digestif,https://github.com/astoff/digestif.git,,,0.2-1,lua5_3,
dkjson,,,,,,
fifo,,,,,,
gitsigns.nvim,https://github.com/lewis6991/gitsigns.nvim.git,,,,lua5_1,
http,,,,0.3-0,,vcunat
inspect,,,,,,
ldbus,,,http://luarocks.org/dev,,,
ldoc,https://github.com/stevedonovan/LDoc.git,,,,,
lgi,,,,,,
linenoise,https://github.com/hoelzro/lua-linenoise.git,,,,,
ljsyscall,,,,,lua5_1,lblasc
lpeg,,,,,,vyp
lpeg_patterns,,,,,,
lpeglabel,,,,,,
lpty,,,,,,
lrexlib-gnu,,,,,,
lrexlib-pcre,,,,,,vyp
lrexlib-posix,,,,,,
lua-cjson,,,,,,
lua-cmsgpack,,,,,,
lua-iconv,,,,,,
lua-lsp,,,,,,
lua-messagepack,,,,,,
lua-resty-http,,,,,,
lua-resty-jwt,,,,,,
lua-resty-openidc,,,,,,
lua-resty-openssl,,,,,,
lua-resty-session,,,,,,
lua-term,,,,,,
lua-toml,,,,,,
lua-zlib,,,,,,koral
lua_cliargs,https://github.com/amireh/lua_cliargs.git,,,,,
luabitop,https://github.com/teto/luabitop.git,,,,,
luacheck,,,,,,
luacov,,,,,,
luadbi,,,,,,
luadbi-mysql,,,,,,
luadbi-postgresql,,,,,,
luadbi-sqlite3,,,,,,
luaepnf,,,,,,
luaevent,,,,,,
luaexpat,,,,1.3.0-1,,arobyn flosse
luaffi,,,http://luarocks.org/dev,,,
luafilesystem,,,,1.7.0-2,,flosse
lualogging,,,,,,
luaossl,,,,,lua5_1,
luaposix,,,,34.1.1-1,,vyp lblasc
luarepl,,,,,,
luasec,,,,,,flosse
luasocket,,,,,,
luasql-sqlite3,,,,,,vyp
luassert,,,,,,
luasystem,,,,,,
luautf8,,,,,,pstn
luazip,,,,,,
lua-yajl,,,,,,pstn
luuid,,,,,,
luv,,,,1.30.0-0,,
lyaml,,,,,,lblasc
markdown,,,,,,
mediator_lua,,,,,,
mpack,,,,,,
moonscript,,,,,,arobyn
nvim-client,https://github.com/neovim/lua-client.git,,,,,
penlight,https://github.com/Tieske/Penlight.git,,,,,
plenary.nvim,https://github.com/nvim-lua/plenary.nvim.git,,,,lua5_1,
rapidjson,https://github.com/xpol/lua-rapidjson.git,,,,,
readline,,,,,,
say,https://github.com/Olivine-Labs/say.git,,,,,
std._debug,https://github.com/lua-stdlib/_debug.git,,,,,
std.normalize,git://github.com/lua-stdlib/normalize.git,,,,,
stdlib,,,,41.2.2,,vyp
vstruct,https://github.com/ToxicFrog/vstruct.git,,,,,

1 name src ref server version luaversion maintainers
2 alt-getopt arobyn
3 ansicolors bit32 5.3.0-1 lua5_1 lblasc
4 bit32 argparse https://github.com/luarocks/argparse.git 5.3.0-1 lua5_1 lblasc
5 argparse basexx https://github.com/teto/basexx.git
6 basexx binaryheap https://github.com/Tieske/binaryheap.lua vcunat
7 binaryheap busted vcunat
8 busted cassowary marsam alerque
9 cassowary compat53 0.7-1 marsam alerque vcunat
10 compat53 cosmo 0.7-1 vcunat marsam
11 cosmo coxpcall 1.17.0-1 marsam
12 coxpcall cqueues 1.17.0-1 vcunat
13 cqueues cyrussasl https://github.com/JorjBauer/lua-cyrussasl.git vcunat
14 cyrussasl digestif https://github.com/astoff/digestif.git 0.2-1 lua5_3
15 digestif dkjson 0.2-1 lua5_3
16 dkjson fifo
17 fifo gitsigns.nvim https://github.com/lewis6991/gitsigns.nvim.git lua5_1
18 gitsigns.nvim http 0.3-0 lua5_1 vcunat
19 http inspect 0.3-0 vcunat
20 inspect ldbus http://luarocks.org/dev
21 ldbus ldoc https://github.com/stevedonovan/LDoc.git http://luarocks.org/dev
22 ldoc lgi
23 lgi linenoise https://github.com/hoelzro/lua-linenoise.git
24 linenoise ljsyscall lua5_1 lblasc
25 ljsyscall lpeg lua5_1 lblasc vyp
26 lpeg lpeg_patterns vyp
27 lpeg_patterns lpeglabel
28 lpeglabel lpty
29 lpty lrexlib-gnu
30 lrexlib-gnu lrexlib-pcre vyp
31 lrexlib-pcre lrexlib-posix vyp
32 lrexlib-posix lua-cjson
33 ltermbox lua-cmsgpack
34 lua-cjson lua-iconv
35 lua-cmsgpack lua-lsp
36 lua-iconv lua-messagepack
37 lua-lsp lua-resty-http http://luarocks.org/dev
38 lua-messagepack lua-resty-jwt
39 lua-resty-http lua-resty-openidc
40 lua-resty-jwt lua-resty-openssl
41 lua-resty-openidc lua-resty-session
42 lua-resty-openssl lua-term
43 lua-resty-session lua-toml
44 lua-term lua-zlib koral
45 lua-toml lua_cliargs https://github.com/amireh/lua_cliargs.git
46 lua-zlib luabitop https://github.com/teto/luabitop.git koral
47 lua_cliargs luacheck
48 luabitop luacov
49 luacheck luadbi
50 luacov luadbi-mysql
51 luadbi luadbi-postgresql
52 luadbi-mysql luadbi-sqlite3
53 luadbi-postgresql luaepnf
54 luadbi-sqlite3 luaevent
55 luadoc luaexpat 1.3.0-1 arobyn flosse
56 luaepnf luaffi http://luarocks.org/dev
57 luaevent luafilesystem 1.7.0-2 flosse
58 luaexpat lualogging 1.3.0-1 arobyn flosse
59 luaffi luaossl http://luarocks.org/dev lua5_1
60 luafilesystem luaposix 1.7.0-2 34.1.1-1 flosse vyp lblasc
61 lualogging luarepl
62 luaossl luasec lua5_1 flosse
63 luaposix luasocket 34.1.1-1 vyp lblasc
64 luarepl luasql-sqlite3 vyp
65 luasec luassert flosse
66 luasocket luasystem
67 luasql-sqlite3 luautf8 vyp pstn
68 luassert luazip
69 luasystem lua-yajl pstn
70 luautf8 luuid pstn
71 luazip luv 1.30.0-0
72 lua-yajl lyaml pstn lblasc
73 luuid markdown
74 luv mediator_lua 1.30.0-0
75 lyaml mpack lblasc
76 markdown moonscript arobyn
77 mediator_lua nvim-client https://github.com/neovim/lua-client.git
78 mpack penlight https://github.com/Tieske/Penlight.git
79 moonscript plenary.nvim https://github.com/nvim-lua/plenary.nvim.git lua5_1 arobyn
80 nvim-client rapidjson https://github.com/xpol/lua-rapidjson.git
81 penlight readline
82 plenary.nvim say https://github.com/Olivine-Labs/say.git lua5_1
83 rapidjson std._debug https://github.com/lua-stdlib/_debug.git
84 readline std.normalize git://github.com/lua-stdlib/normalize.git
85 say stdlib 41.2.2 vyp
86 std._debug vstruct https://github.com/ToxicFrog/vstruct.git
std.normalize
stdlib vyp
vstruct

View file

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -p nix-prefetch-git luarocks-nix python3 python3Packages.GitPython nix -i python3
#!nix-shell update-luarocks-shell.nix -i python3
# format:
# $ nix run nixpkgs.python3Packages.black -c black update.py
@ -19,7 +19,7 @@ import logging
import textwrap
from multiprocessing.dummy import Pool
from typing import List, Tuple
from typing import List, Tuple, Optional
from pathlib import Path
log = logging.getLogger()
@ -50,10 +50,21 @@ FOOTER="""
@dataclass
class LuaPlugin:
name: str
version: str
server: str
luaversion: str
maintainers: str
'''Name of the plugin, as seen on luarocks.org'''
src: str
'''address to the git repository'''
ref: Optional[str]
'''git reference (branch name/tag)'''
version: Optional[str]
'''Set it to pin a package '''
server: Optional[str]
'''luarocks.org registers packages under different manifests.
Its value can be 'http://luarocks.org/dev'
'''
luaversion: Optional[str]
'''Attribue of the lua interpreter if a package is available only for a specific lua version'''
maintainers: Optional[str]
''' Optional string listing maintainers separated by spaces'''
@property
def normalized_name(self) -> str:
@ -149,16 +160,33 @@ def generate_pkg_nix(plug: LuaPlugin):
Our cache key associates "p.name-p.version" to its rockspec
'''
log.debug("Generating nix expression for %s", plug.name)
cmd = [ "luarocks", "nix", plug.name]
cmd = [ "luarocks", "nix"]
if plug.server:
cmd.append(f"--only-server={plug.server}")
if plug.maintainers:
cmd.append(f"--maintainers={plug.maintainers}")
if plug.version:
cmd.append(plug.version)
# updates plugin directly from its repository
print("server: [%s]" % plug.server)
# if plug.server == "src":
if plug.src != "":
if plug.src is None:
msg = "src must be set when 'version' is set to \"src\" for package %s" % plug.name
log.error(msg)
raise RuntimeError(msg)
log.debug("Updating from source %s", plug.src)
cmd.append(plug.src)
# update the plugin from luarocks
else:
cmd.append(plug.name)
if plug.version and plug.version != "src":
cmd.append(plug.version)
#
if plug.server != "src" and plug.server:
cmd.append(f"--only-server={plug.server}")
if plug.luaversion:
with CleanEnvironment():
@ -169,7 +197,7 @@ def generate_pkg_nix(plug: LuaPlugin):
lua_drv_path=subprocess.check_output(cmd2, text=True).strip()
cmd.append(f"--lua-dir={lua_drv_path}/bin")
log.debug("running %s", cmd)
log.debug("running %s", ' '.join(cmd))
output = subprocess.check_output(cmd, text=True)
return (plug, output)
@ -191,3 +219,4 @@ if __name__ == "__main__":
main()
# vim: set ft=python noet fdm=manual fenc=utf-8 ff=unix sts=0 sw=4 ts=4 :

View file

@ -1,12 +1,13 @@
{ nixpkgs ? import ../.. { }
}:
with nixpkgs;
let
pyEnv = python3.withPackages(ps: [ ps.GitPython ]);
in
mkShell {
packages = [
bash
pyEnv
luarocks-nix
nix-prefetch-scripts
parallel
];
LUAROCKS_NIXPKGS_PATH = toString nixpkgs.path;
}

View file

@ -7,8 +7,7 @@
}:
{
name ? "${attrs.pname}-${attrs.version}"
pname
, version
# by default prefix `name` e.g. "lua5.2-${name}"
@ -60,7 +59,9 @@ name ? "${attrs.pname}-${attrs.version}"
# The two above arguments have access to builder variables -- e.g. to $out
# relative to srcRoot, path to the rockspec to use when using rocks
, rockspecFilename ? "../*.rockspec"
, rockspecFilename ? null
# relative to srcRoot, path to folder that contains the expected rockspec
, rockspecDir ? "."
# must be set for packages that don't have a rock
, knownRockspec ? null
@ -71,6 +72,9 @@ name ? "${attrs.pname}-${attrs.version}"
# Keep extra attributes from `attrs`, e.g., `patchPhase', etc.
let
generatedRockspecFilename = "${rockspecDir}/${pname}-${version}.rockspec";
# TODO fix warnings "Couldn't load rockspec for ..." during manifest
# construction -- from initial investigation, appears it will require
# upstream luarocks changes to fix cleanly (during manifest construction,
@ -144,7 +148,7 @@ in
toLuaModule ( lua.stdenv.mkDerivation (
builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // {
name = namePrefix + name;
name = namePrefix + pname + "-" + version;
buildInputs = [ wrapLua lua.pkgs.luarocks ]
++ buildInputs
@ -159,20 +163,8 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
# @-patterns do not capture formal argument default values, so we need to
# explicitly inherit this for it to be available as a shell variable in the
# builder
inherit rockspecFilename;
inherit rocksSubdir;
# enabled only for src.rock
setSourceRoot= let
name_only= lib.getName name;
in
lib.optionalString (knownRockspec == null) ''
# format is rockspec_basename/source_basename
# rockspec can set it via spec.source.dir
folder=$(find . -mindepth 2 -maxdepth 2 -type d -path '*${name_only}*/*'|head -n1)
sourceRoot="$folder"
'';
configurePhase = ''
runHook preConfigure
@ -181,6 +173,9 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
EOF
export LUAROCKS_CONFIG="$PWD/${luarocks_config}";
''
+ lib.optionalString (rockspecFilename == null) ''
rockspecFilename="${generatedRockspecFilename}"
''
+ lib.optionalString (knownRockspec != null) ''
# prevents the following type of error:
@ -192,6 +187,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
runHook postConfigure
'';
# TODO could be moved to configurePhase
buildPhase = ''
runHook preBuild

File diff suppressed because it is too large Load diff

View file

@ -20,7 +20,7 @@ else
attrs
//
{
name = "lua${lua.luaversion}-" + attrs.name;
name = "lua${lua.luaversion}-" + attrs.pname + "-" + attrs.version;
propagatedBuildInputs = propagatedBuildInputs ++ [
lua # propagate it for its setup-hook
];

View file

@ -121,6 +121,11 @@ with super;
sha256 = "0gfvvbri9kyzhvq3bvdbj2l6mwvlz040dk4mrd5m9gz79f7w109c";
})
];
# there is only a rockspec.in in the repo, the actual rockspec must be generated
preConfigure = ''
make rock
'';
});
lrexlib-gnu = super.lrexlib-gnu.override({
@ -141,10 +146,6 @@ with super;
];
});
ltermbox = super.ltermbox.override( {
disabled = !isLua51 || isLuaJIT;
});
lua-iconv = super.lua-iconv.override({
buildInputs = [
pkgs.libiconv
@ -348,6 +349,19 @@ with super;
'';
});
std-_debug = super.std-_debug.overrideAttrs(oa: {
# run make to generate lib/std/_debug/version.lua
preConfigure = ''
make all
'';
});
std-normalize = super.std-normalize.overrideAttrs(oa: {
# run make to generate lib/std/_debug/version.lua
preConfigure = ''
make all
'';
});
# aliases
cjson = super.lua-cjson;

View file

@ -5,7 +5,10 @@ luarocks.overrideAttrs(old: {
src = fetchFromGitHub {
owner = "nix-community";
repo = "luarocks-nix";
rev = "nix_v3.5.0-1";
sha256 = "sha256-jcgshxAuuc8QizpYL/2K3PKYWiKsnF/8BJAUaryvEvQ=";
rev = "test-speedup";
sha256 = "sha256-WfzLSpIp0V7Ib4sjYvoJHF+/vHaieccvfVAr5W47QsQ=";
};
patches = [];
meta.mainProgram = "luarocks";
})

View file

@ -99,8 +99,8 @@ with self; {
luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { };
luxio = buildLuaPackage rec {
name = "luxio-${version}";
luxio = buildLuaPackage {
pname = "luxio";
version = "13";
src = fetchurl {