Merge pull request #178158 from teto/luarocks-add-sqlite

This commit is contained in:
Matthieu Coudron 2022-06-18 20:44:08 +02:00 committed by GitHub
commit 0633b702a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 101 additions and 14 deletions

View File

@ -86,6 +86,7 @@ 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,,,,,
sqlite,,,,,,
std._debug,https://github.com/lua-stdlib/_debug.git,,,,,
std.normalize,https://github.com/lua-stdlib/normalize.git,,,,,
stdlib,,,,41.2.2,,vyp

Can't render this file because it has a wrong number of fields in line 72.

View File

@ -103,7 +103,6 @@
, golint
, gomodifytags
, gopls
, gotags
, gotools
, iferr
, impl
@ -1042,7 +1041,6 @@ self: super: {
gomodifytags
gopls
# gorename
# gotags
gotools # contains staticcheck
# guru
iferr

View File

@ -4,6 +4,7 @@
, wrapLua
# Whether the derivation provides a lua module or not.
, toLuaModule
, luarocksCheckHook
}:
{
@ -42,6 +43,7 @@ pname
, passthru ? {}
, doCheck ? false
, doInstallCheck ? false
# Non-Lua / system (e.g. C library) dependencies. Is a list of deps, where
# each dep is either a derivation, or an attribute set like
@ -97,10 +99,12 @@ 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 luarocksDrv.propagatedBuildInputs);
(lua.pkgs.requiredLuaModules (luarocksDrv.nativeBuildInputs ++ luarocksDrv.propagatedBuildInputs));
# example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ]
externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs));
externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (
luarocksDrv.nativeBuildInputs ++ luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs)
);
externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps;
luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation (
@ -108,15 +112,17 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
name = namePrefix + pname + "-" + version;
buildInputs = [ wrapLua lua.pkgs.luarocks ]
nativeBuildInputs = [
wrapLua
lua.pkgs.luarocks
]
++ buildInputs
++ lib.optionals doCheck checkInputs
++ lib.optionals doCheck ([ luarocksCheckHook ] ++ checkInputs)
++ (map (d: d.dep) externalDeps')
;
# propagate lua to active setup-hook in nix-shell
propagatedBuildInputs = propagatedBuildInputs ++ [ lua ];
inherit doCheck;
# @-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
@ -190,6 +196,14 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
runHook postCheck
'';
LUAROCKS_CONFIG="$PWD/${luarocks_config}";
shellHook = ''
runHook preShell
export LUAROCKS_CONFIG="$PWD/${luarocks_config}";
runHook postShell
'';
passthru = {
inherit lua; # The lua interpreter
inherit externalDeps;

View File

@ -24,4 +24,9 @@ in {
mv hook.sh $out
'';
luarocksCheckHook = callPackage ({ luarocks }:
makeSetupHook {
name = "luarocks-check-hook";
deps = [ luarocks ];
} ./luarocks-check-hook.sh) {};
}

View File

@ -0,0 +1,18 @@
# Setup hook for checking whether Python imports succeed
echo "Sourcing luarocks-check-hook.sh"
luarocksCheckPhase () {
echo "Executing luarocksCheckPhase"
runHook preCheck
luarocks test
runHook postCheck
echo "Finished executing luarocksCheckPhase"
}
if [ -z "${dontLuarocksCheck-}" ] && [ -z "${checkPhase-}" ]; then
echo "Using luarocksCheckPhase"
checkPhase+=" luarocksCheckPhase"
fi

View File

@ -2546,6 +2546,38 @@ buildLuarocksPackage {
};
}) {};
sqlite = callPackage({ buildLuarocksPackage, luaOlder, luaAtLeast
, fetchgit, luv
}:
buildLuarocksPackage {
pname = "sqlite";
version = "v1.2.2-0";
knownRockspec = (fetchurl {
url = "mirror://luarocks/sqlite-v1.2.2-0.rockspec";
sha256 = "0jxsl9lpxsbzc6s5bwmh27mglkqz1299lz68vfxayvailwl3xbxm";
}).outPath;
src = fetchgit ( removeAttrs (builtins.fromJSON ''{
"url": "https://github.com/tami5/sqlite.lua.git",
"rev": "6c00ab414dc1b69621b145908c582b747f24b46e",
"date": "2022-06-17T15:57:13+03:00",
"path": "/nix/store/637s46bsvsxfnzmy6ygig3y0vqmf3r8p-sqlite.lua",
"sha256": "0ckifx6xxrannn9szacgiiqjsp4rswghxscdl3s411dhas8djj1m",
"fetchLFS": false,
"fetchSubmodules": true,
"deepClone": false,
"leaveDotGit": false
}
'') ["date" "path"]) ;
propagatedBuildInputs = [ luv ];
meta = {
homepage = "https://github.com/tami5/sqlite.lua";
description = "SQLite/LuaJIT binding and a highly opinionated wrapper for storing, retrieving, caching, and persisting [SQLite] databases";
license.fullName = "MIT";
};
}) {};
std-_debug = callPackage({ buildLuarocksPackage, luaOlder, luaAtLeast
, fetchgit, lua
}:

View File

@ -15,7 +15,7 @@ with prev;
});
busted = prev.busted.overrideAttrs(oa: {
nativeBuildInputs = [
nativeBuildInputs = oa.nativeBuildInputs ++ [
pkgs.installShellFiles
];
postConfigure = ''
@ -30,9 +30,6 @@ with prev;
});
cqueues = (prev.lib.overrideLuarocks prev.cqueues (drv: {
nativeBuildInputs = [
pkgs.gnum4
];
externalDeps = [
{ name = "CRYPTO"; dep = pkgs.openssl; }
{ name = "OPENSSL"; dep = pkgs.openssl; }
@ -46,6 +43,11 @@ with prev;
date = head rel;
rev = last (splitString "-" (last rel));
in "${date}-${rev}";
nativeBuildInputs = oa.nativeBuildInputs ++ [
pkgs.gnum4
];
# Upstream rockspec is pointlessly broken into separate rockspecs, per Lua
# version, which doesn't work well for us, so modify it
postConfigure = let inherit (prev.cqueues) pname; in ''
@ -111,8 +113,8 @@ with prev;
propagatedBuildInputs = with pkgs.lib; optional (!isLuaJIT) luaffi;
});
lgi = prev.lib.overrideLuarocks prev.lgi (drv: {
nativeBuildInputs = [
lgi = prev.lgi.overrideAttrs (oa: {
nativeBuildInputs = oa.nativeBuildInputs ++ [
pkgs.pkg-config
];
buildInputs = [
@ -415,6 +417,23 @@ with prev;
'';
});
sqlite = prev.lib.overrideLuarocks prev.sqlite (drv: {
doCheck = true;
checkInputs = [ final.plenary-nvim pkgs.neovim-unwrapped ];
# we override 'luarocks test' because otherwise neovim doesn't find/load the plenary plugin
checkPhase = ''
export LIBSQLITE="${pkgs.sqlite.out}/lib/libsqlite3.so"
export HOME="$TMPDIR";
nvim --headless -i NONE \
-u test/minimal_init.vim --cmd "set rtp+=${pkgs.vimPlugins.plenary-nvim}" \
-c "PlenaryBustedDirectory test/auto/ { minimal_init = './test/minimal_init.vim' }"
'';
});
std-_debug = prev.std-_debug.overrideAttrs(oa: {
# run make to generate lib/std/_debug/version.lua
preConfigure = ''

View File

@ -50,7 +50,7 @@ in
getLuaCPath = drv: getPath drv luaLib.luaCPathList;
inherit (callPackage ../development/interpreters/lua-5/hooks { inherit (args) lib;})
lua-setup-hook;
luarocksCheckHook lua-setup-hook;
inherit lua callPackage;
inherit buildLuaPackage buildLuarocksPackage buildLuaApplication;