luaPackages: update

- luarocks-nix: bumped to pass args too, `package_X = callPackage ...`.
  It allows to remove the annoying `with self`.
  This new version disables tests (because broken) and now emits derivation
  with a callPackage in front.
- replaced X.override with lib.overrideLuarocks, it should be used
whenever buildInputs/extraVariables is changed since it impacts the
generated luarocks config.
Once structured attributes are in, it will be easier to have the
luarocks config generated by a hook and we probably will be able to
replace all overrideLuarocks by overrideAttrs.
This commit is contained in:
Matthieu Coudron 2021-10-04 00:10:46 +02:00 committed by Matthieu Coudron
parent ecd018bb00
commit 253af9151f
7 changed files with 626 additions and 369 deletions

View File

@ -33,8 +33,7 @@ TMP_FILE="$(mktemp)"
GENERATED_NIXFILE="pkgs/development/lua-modules/generated-packages.nix"
LUAROCKS_CONFIG="$NIXPKGS_PATH/maintainers/scripts/luarocks-config.lua"
HEADER = """
/* {GENERATED_NIXFILE} is an auto-generated file -- DO NOT EDIT!
HEADER = """/* {GENERATED_NIXFILE} is an auto-generated file -- DO NOT EDIT!
Regenerate it with:
nixpkgs$ ./maintainers/scripts/update-luarocks-packages
@ -99,9 +98,8 @@ class LuaEditor(Editor):
header2 = textwrap.dedent(
# header2 = inspect.cleandoc(
"""
{ self, stdenv, lib, fetchurl, fetchgit, ... } @ args:
self: super:
with self;
{ self, stdenv, lib, fetchurl, fetchgit, callPackage, ... } @ args:
final: prev:
{
""")
f.write(header2)
@ -199,6 +197,7 @@ def generate_pkg_nix(plug: LuaPlugin):
log.debug("running %s", ' '.join(cmd))
output = subprocess.check_output(cmd, text=True)
output = "callPackage(" + output.strip() + ") {};\n\n"
return (plug, output)
def main():

View File

@ -25,7 +25,6 @@ pname
# propagate build dependencies so in case we have A -> B -> C,
# C can import package A propagated by B
, propagatedBuildInputs ? []
, propagatedNativeBuildInputs ? []
# used to disable derivation, useful for specific lua versions
# TODO move from this setting meta.broken to a 'disabled' attribute on the
@ -50,7 +49,7 @@ pname
# The latter is used to work-around luarocks having a problem with
# multiple-output derivations as external deps:
# https://github.com/luarocks/luarocks/issues/766<Paste>
, externalDeps ? lib.unique (lib.filter (drv: !drv ? luaModule) (propagatedBuildInputs ++ buildInputs))
, externalDeps ? []
# Appended to the generated luarocks config
, extraConfig ? ""
@ -74,7 +73,6 @@ pname
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,
@ -83,7 +81,7 @@ let
luarocks_config = "luarocks-config.lua";
luarocks_content = let
generatedConfig = lua.pkgs.lib.generateLuarocksConfig {
inherit externalDeps;
externalDeps = externalDeps ++ externalDepsGenerated;
inherit extraVariables;
inherit rocksSubdir;
inherit requiredLuaRocks;
@ -99,12 +97,13 @@ let
# Filter out the lua derivation itself from the Lua module dependency
# closure, as it doesn't have a rock tree :)
requiredLuaRocks = lib.filter (d: d ? luaModule)
(lua.pkgs.requiredLuaModules propagatedBuildInputs);
(lua.pkgs.requiredLuaModules luarocksDrv.propagatedBuildInputs);
# example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs));
externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps;
in
toLuaModule ( lua.stdenv.mkDerivation (
luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation (
builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariables"] // {
name = namePrefix + pname + "-" + version;
@ -146,13 +145,12 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
runHook postConfigure
'';
# TODO could be moved to configurePhase
buildPhase = ''
runHook preBuild
nix_debug "Using LUAROCKS_CONFIG=$LUAROCKS_CONFIG"
LUAROCKS=luarocks
LUAROCKS=${lua.pkgs.luarocks}/bin/luarocks
if (( ''${NIX_DEBUG:-0} >= 1 )); then
LUAROCKS="$LUAROCKS --verbose"
fi
@ -195,6 +193,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
passthru = {
inherit lua; # The lua interpreter
inherit externalDeps;
inherit luarocks_content;
} // passthru;
meta = {
@ -203,4 +202,6 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
maintainers = (meta.maintainers or []) ++ [ ];
broken = disabled;
} // meta;
}))
}));
in
luarocksDrv

View File

@ -15,7 +15,7 @@ let
overridenPackages = import ./overrides.nix { inherit pkgs; };
generatedPackages = if (builtins.pathExists ./generated-packages.nix) then
pkgs.callPackage ./generated-packages.nix { } else (final: prev: {});
(final: prev: pkgs.callPackage ./generated-packages.nix { inherit (final) callPackage; } final prev) else (final: prev: {});
extensible-self = lib.makeExtensible
(extends overrides

File diff suppressed because it is too large Load Diff

View File

@ -5,8 +5,20 @@ let
in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules));
# Check whether a derivation provides a lua module.
hasLuaModule = drv: drv ? luaModule;
/*
Use this to override the arguments passed to buildLuarocksPackage
*/
overrideLuarocks = drv: f: (drv.override (args: args // {
buildLuarocksPackage = drv: (args.buildLuarocksPackage drv).override f;
})) // {
overrideScope = scope: overrideLuarocks (drv.overrideScope scope) f;
};
in
rec {
inherit overrideLuarocks;
inherit hasLuaModule requiredLuaModules;
luaPathList = [

View File

@ -1,11 +1,11 @@
{ pkgs, ... }:
self: super:
with super;
{ pkgs }:
final: prev:
with prev;
{
##########################################3
#### manual fixes for generated packages
##########################################3
bit32 = super.bit32.override({
bit32 = prev.bit32.overrideAttrs(oa: {
# Small patch in order to no longer redefine a Lua 5.2 function that Luajit
# 2.1 also provides, see https://github.com/LuaJIT/LuaJIT/issues/325 for
# more
@ -14,7 +14,7 @@ with super;
];
});
busted = super.busted.override({
busted = prev.busted.overrideAttrs(oa: {
postConfigure = ''
substituteInPlace ''${rockspecFilename} \
--replace "'lua_cliargs = 3.0-1'," "'lua_cliargs >= 3.0-1',"
@ -25,14 +25,7 @@ with super;
'';
});
cqueues = super.cqueues.override(rec {
# Parse out a version number without the Lua version inserted
version = with pkgs.lib; let
version' = super.cqueues.version;
rel = splitVersion version';
date = head rel;
rev = last (splitString "-" (last rel));
in "${date}-${rev}";
cqueues = (prev.lib.overrideLuarocks prev.cqueues (drv: {
nativeBuildInputs = [
pkgs.gnum4
];
@ -41,9 +34,17 @@ with super;
{ name = "OPENSSL"; dep = pkgs.openssl; }
];
disabled = luaOlder "5.1" || luaAtLeast "5.4";
})).overrideAttrs(oa: rec {
# Parse out a version number without the Lua version inserted
version = with pkgs.lib; let
version' = prev.cqueues.version;
rel = splitVersion version';
date = head rel;
rev = last (splitString "-" (last rel));
in "${date}-${rev}";
# Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
# version, which doesn't work well for us, so modify it
postConfigure = let inherit (super.cqueues) pname; in ''
postConfigure = let inherit (prev.cqueues) pname; in ''
# 'all' target auto-detects correct Lua version, which is fine for us as
# we only have the right one available :)
sed -Ei ''${rockspecFilename} \
@ -56,13 +57,13 @@ with super;
'';
});
cyrussasl = super.cyrussasl.override({
cyrussasl = prev.lib.overrideLuarocks prev.cyrussasl (drv: {
externalDeps = [
{ name = "LIBSASL"; dep = pkgs.cyrus_sasl; }
];
});
http = super.http.override({
http = prev.http.overrideAttrs(oa: {
patches = [
(pkgs.fetchpatch {
name = "invalid-state-progression.patch";
@ -76,7 +77,7 @@ with super;
*/
});
ldbus = super.ldbus.override({
ldbus = prev.lib.overrideLuarocks prev.ldbus (drv: {
extraVariables = {
DBUS_DIR="${pkgs.dbus.lib}";
DBUS_ARCH_INCDIR="${pkgs.dbus.lib}/lib/dbus-1.0/include";
@ -87,7 +88,7 @@ with super;
];
});
ljsyscall = super.ljsyscall.override(rec {
ljsyscall = prev.ljsyscall.overrideAttrs(oa: rec {
version = "unstable-20180515";
# package hasn't seen any release for a long time
src = pkgs.fetchFromGitHub {
@ -106,7 +107,7 @@ with super;
propagatedBuildInputs = with pkgs.lib; optional (!isLuaJIT) luaffi;
});
lgi = super.lgi.override({
lgi = prev.lib.overrideLuarocks prev.lgi (drv: {
nativeBuildInputs = [
pkgs.pkg-config
];
@ -128,31 +129,31 @@ with super;
'';
});
lrexlib-gnu = super.lrexlib-gnu.override({
lrexlib-gnu = prev.lib.overrideLuarocks prev.lrexlib-gnu (drv: {
buildInputs = [
pkgs.gnulib
];
});
lrexlib-pcre = super.lrexlib-pcre.override({
lrexlib-pcre = prev.lib.overrideLuarocks prev.lrexlib-pcre (drv: {
externalDeps = [
{ name = "PCRE"; dep = pkgs.pcre; }
];
});
lrexlib-posix = super.lrexlib-posix.override({
lrexlib-posix = prev.lib.overrideLuarocks prev.lrexlib-posix (drv: {
buildInputs = [
pkgs.glibc.dev
];
});
lua-iconv = super.lua-iconv.override({
lua-iconv = prev.lib.overrideLuarocks prev.lua-iconv (drv: {
buildInputs = [
pkgs.libiconv
];
});
lua-lsp = super.lua-lsp.override({
lua-lsp = prev.lua-lsp.overrideAttrs(oa: {
# until Alloyed/lua-lsp#28
postConfigure = ''
substituteInPlace ''${rockspecFilename} \
@ -160,14 +161,14 @@ with super;
'';
});
lua-zlib = super.lua-zlib.override({
lua-zlib = prev.lib.overrideLuarocks prev.lua-zlib (drv: {
buildInputs = [
pkgs.zlib.dev
];
disabled = luaOlder "5.1" || luaAtLeast "5.4";
});
luadbi-mysql = super.luadbi-mysql.override({
luadbi-mysql = prev.lib.overrideLuarocks prev.luadbi-mysql (drv: {
extraVariables = {
# Can't just be /include and /lib, unfortunately needs the trailing 'mysql'
MYSQL_INCDIR="${pkgs.libmysqlclient.dev}/include/mysql";
@ -179,19 +180,19 @@ with super;
];
});
luadbi-postgresql = super.luadbi-postgresql.override({
luadbi-postgresql = prev.lib.overrideLuarocks prev.luadbi-postgresql (drv: {
buildInputs = [
pkgs.postgresql
];
});
luadbi-sqlite3 = super.luadbi-sqlite3.override({
luadbi-sqlite3 = prev.lib.overrideLuarocks prev.luadbi-sqlite3 (drv: {
externalDeps = [
{ name = "SQLITE"; dep = pkgs.sqlite; }
];
});
luaevent = super.luaevent.override({
luaevent = prev.lib.overrideLuarocks prev.luaevent (drv: {
propagatedBuildInputs = [
luasocket
];
@ -201,7 +202,7 @@ with super;
disabled = luaOlder "5.1" || luaAtLeast "5.4";
});
luaexpat = super.luaexpat.override({
luaexpat = prev.lib.overrideLuarocks prev.luaexpat (drv: {
externalDeps = [
{ name = "EXPAT"; dep = pkgs.expat; }
];
@ -212,59 +213,57 @@ with super;
# TODO Somehow automatically amend buildInputs for things that need luaffi
# but are in luajitPackages?
luaffi = super.luaffi.override({
luaffi = prev.lib.overrideLuarocks prev.luaffi (drv: {
# The packaged .src.rock version is pretty old, and doesn't work with Lua 5.3
src = pkgs.fetchFromGitHub {
owner = "facebook"; repo = "luaffifb";
rev = "532c757e51c86f546a85730b71c9fef15ffa633d";
sha256 = "1nwx6sh56zfq99rcs7sph0296jf6a9z72mxknn0ysw9fd7m1r8ig";
};
knownRockspec = with super.luaffi; "${pname}-${version}.rockspec";
knownRockspec = with prev.luaffi; "${pname}-${version}.rockspec";
disabled = luaOlder "5.1" || luaAtLeast "5.4" || isLuaJIT;
});
luaossl = super.luaossl.override({
luaossl = prev.lib.overrideLuarocks prev.luaossl (drv: {
externalDeps = [
{ name = "CRYPTO"; dep = pkgs.openssl; }
{ name = "OPENSSL"; dep = pkgs.openssl; }
];
});
luasec = super.luasec.override({
luasec = prev.lib.overrideLuarocks prev.luasec (drv: {
externalDeps = [
{ name = "OPENSSL"; dep = pkgs.openssl; }
];
});
luasql-sqlite3 = super.luasql-sqlite3.override({
luasql-sqlite3 = prev.lib.overrideLuarocks prev.luasql-sqlite3 (drv: {
externalDeps = [
{ name = "SQLITE"; dep = pkgs.sqlite; }
];
});
luasystem = super.luasystem.override({
buildInputs = pkgs.lib.optionals pkgs.stdenv.isLinux [
pkgs.glibc
];
});
luasystem = prev.lib.overrideLuarocks prev.luasystem (drv: { buildInputs = [ pkgs.glibc.out ]; });
luazip = super.luazip.override({
luazip = prev.lib.overrideLuarocks prev.luazip (drv: {
buildInputs = [
pkgs.zziplib
];
});
lua-yajl = super.lua-yajl.override({
lua-yajl = prev.lib.overrideLuarocks prev.lua-yajl (drv: {
buildInputs = [
pkgs.yajl
];
});
luuid = super.luuid.override(old: {
luuid = (prev.lib.overrideLuarocks prev.luuid (drv: {
externalDeps = [
{ name = "LIBUUID"; dep = pkgs.libuuid; }
];
meta = old.meta // {
disabled = luaOlder "5.1" || (luaAtLeast "5.4");
})).overrideAttrs(oa: {
meta = oa.meta // {
platforms = pkgs.lib.platforms.linux;
};
# Trivial patch to make it work in both 5.1 and 5.2. Basically just the
@ -276,13 +275,12 @@ with super;
patches = [
./luuid.patch
];
postConfigure = let inherit (super.luuid) version pname; in ''
postConfigure = let inherit (prev.luuid) version pname; in ''
sed -Ei ''${rockspecFilename} -e 's|lua >= 5.2|lua >= 5.1,|'
'';
disabled = luaOlder "5.1" || (luaAtLeast "5.4");
});
luv = super.luv.override({
luv = prev.lib.overrideLuarocks prev.luv (drv: {
# Use system libuv instead of building local and statically linking
# This is a hacky way to specify -DWITH_SHARED_LIBUV=ON which
# is not possible with luarocks and the current luv rockspec
@ -296,8 +294,8 @@ with super;
buildInputs = [ pkgs.libuv ];
passthru = {
libluv = self.luv.override ({
preBuild = self.luv.preBuild + ''
libluv = final.luv.overrideAttrs (oa: {
preBuild = final.luv.preBuild + ''
sed -i 's,\(option(BUILD_MODULE.*\)ON,\1OFF,' CMakeLists.txt
sed -i 's,\(option(BUILD_SHARED_LIBS.*\)OFF,\1ON,' CMakeLists.txt
sed -i 's,${"\${.*INSTALL_INC_DIR}"},${placeholder "out"}/include/luv,' CMakeLists.txt
@ -312,32 +310,32 @@ with super;
};
});
lyaml = super.lyaml.override({
lyaml = prev.lib.overrideLuarocks prev.lyaml (oa: {
buildInputs = [
pkgs.libyaml
];
});
mpack = super.mpack.override({
mpack = prev.lib.overrideLuarocks prev.mpack (drv: {
buildInputs = [ pkgs.libmpack ];
# the rockspec doesn't use the makefile so you may need to export more flags
USE_SYSTEM_LUA = "yes";
USE_SYSTEM_MPACK = "yes";
});
rapidjson = super.rapidjson.override({
rapidjson = prev.rapidjson.overrideAttrs(oa: {
preBuild = ''
sed -i '/set(CMAKE_CXX_FLAGS/d' CMakeLists.txt
sed -i '/set(CMAKE_C_FLAGS/d' CMakeLists.txt
'';
});
readline = (super.readline.override ({
readline = (prev.lib.overrideLuarocks prev.readline (drv: {
unpackCmd = ''
unzip "$curSrc"
tar xf *.tar.gz
'';
propagatedBuildInputs = super.readline.propagatedBuildInputs ++ [ pkgs.readline ];
propagatedBuildInputs = prev.readline.propagatedBuildInputs ++ [ pkgs.readline.out ];
extraVariables = rec {
READLINE_INCDIR = "${pkgs.readline.dev}/include";
HISTORY_INCDIR = READLINE_INCDIR;
@ -349,14 +347,14 @@ with super;
'';
});
std-_debug = super.std-_debug.overrideAttrs(oa: {
std-_debug = prev.std-_debug.overrideAttrs(oa: {
# run make to generate lib/std/_debug/version.lua
preConfigure = ''
make all
'';
});
std-normalize = super.std-normalize.overrideAttrs(oa: {
std-normalize = prev.std-normalize.overrideAttrs(oa: {
# run make to generate lib/std/_debug/version.lua
preConfigure = ''
make all
@ -365,10 +363,10 @@ with super;
# TODO just while testing, remove afterwards
# toVimPlugin should do it instead
gitsigns-nvim = super.gitsigns-nvim.overrideAttrs(oa: {
gitsigns-nvim = prev.gitsigns-nvim.overrideAttrs(oa: {
nativeBuildInputs = oa.nativeBuildInputs or [] ++ [ pkgs.vimUtils.vimGenDocHook ];
});
# aliases
cjson = super.lua-cjson;
cjson = prev.lua-cjson;
}

View File

@ -5,8 +5,8 @@ luarocks.overrideAttrs(old: {
src = fetchFromGitHub {
owner = "nix-community";
repo = "luarocks-nix";
rev = "test-speedup";
sha256 = "sha256-WfzLSpIp0V7Ib4sjYvoJHF+/vHaieccvfVAr5W47QsQ=";
rev = "standalone";
sha256 = "sha256-53Zi+GTayO9EQTCIVrzPeRRHeIkHLqy0mHyBDzbcQQk=";
};
patches = [];