1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-22 05:31:22 +00:00
nixpkgs/pkgs/top-level/lua-packages.nix

198 lines
6 KiB
Nix
Raw Normal View History

/* This file defines the composition for Lua packages. It has
been factored out of all-packages.nix because there are many of
them. Also, because most Nix expressions for Lua packages are
trivial, most are actually defined here. I.e. there's no function
for each package in a separate file: the call to the function would
be almost as must code as the function itself. */
{ fetchurl, stdenv, lua, unzip, pkgconfig
, pcre, oniguruma, gnulib, tre, glibc, sqlite, openssl, expat
, autoreconfHook, gnum4
, mysql, postgresql, cyrus_sasl
, fetchFromGitHub, which, writeText
, pkgs
, lib
2014-10-12 20:04:52 +01:00
}:
let
packages = ( self:
let
luaAtLeast = lib.versionAtLeast lua.luaversion;
luaOlder = lib.versionOlder lua.luaversion;
isLua51 = (lib.versions.majorMinor lua.version) == "5.1";
isLua52 = (lib.versions.majorMinor lua.version) == "5.2";
isLua53 = lua.luaversion == "5.3";
isLuaJIT = lib.getName lua == "luajit";
lua-setup-hook = callPackage ../development/interpreters/lua-5/setup-hook.nix { };
# Check whether a derivation provides a lua module.
hasLuaModule = drv: drv ? luaModule ;
callPackage = pkgs.newScope self;
requiredLuaModules = drvs: with stdenv.lib; let
modules = filter hasLuaModule drvs;
in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules));
# Convert derivation to a lua module.
toLuaModule = drv:
drv.overrideAttrs( oldAttrs: {
# Use passthru in order to prevent rebuilds when possible.
passthru = (oldAttrs.passthru or {})// {
luaModule = lua;
requiredLuaModules = requiredLuaModules drv.propagatedBuildInputs;
};
});
platformString =
if stdenv.isDarwin then "macosx"
else if stdenv.isFreeBSD then "freebsd"
else if stdenv.isLinux then "linux"
else if stdenv.isSunOS then "solaris"
else throw "unsupported platform";
buildLuaApplication = args: buildLuarocksPackage ({namePrefix="";} // args );
luaPackages: Replace all rockspec packages with generated ones luaPackages replaced by generated ones: - bit32 - compat53 - cqueues - luacyrussasl -> cyrussasl (luarocks name) - luaexpat - luadbi -> luadbi front-end module + separate backend modules luadbi-{mysql,postgresql,sqlite3} - luafilesystem - luaossl - luasec - luasocket - luastdlib -> stdlib (luarocks name) - lrexlib -> lrexlib-pcre (we already have lrexlib-gnu and lrexlib-posix, lrexlib-pcre however appears to be the variant used in mudlet, which is the only current dep in nixpkgs) - luasqlite -> luasql-sqlite3 (luarocks name) - lfs -> luafilesytem (we literally had two manually written luafilesystem expressions, under different names) Changes and additions to overrides to generated luarocks packgaes, including: - busted: Install bash completions along with the zsh ones - cqueues: - Perform minor surgery on the rockspec to allow using a single rockspec to build for all supported Lua versions - Add a patch by @vcunat to work around a build issue - luuid: Wrote a tiny patch to allow for Lua 5.1/Luajit compatibility - General changes: - Sorted the packages - Attempted to make the formatting consistent - Preferenced `.override` instead of `.overrideAttrs` wherever possible Minor changes to other packages to adjust for the Lua package changes: - luakit expression simplified - prosody expression simplified; but users will now need to specify the luadbi backend module they intend to use in withExtraLibs - knot-resolver inputs correctd - mudlet inputs corrected (although this package was and should still be broken)
2019-06-13 12:01:10 +01:00
buildLuarocksPackage = with pkgs.lib; makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix {
inherit toLuaModule;
inherit lua;
});
in
with self; {
getLuaPathList = majorVersion: [
"share/lua/${majorVersion}/?.lua"
"share/lua/${majorVersion}/?/init.lua"
];
getLuaCPathList = majorVersion: [
"lib/lua/${majorVersion}/?.so"
];
# helper functions for dealing with LUA_PATH and LUA_CPATH
getPath = drv: pathListForVersion:
lib.concatMapStringsSep ";" (path: "${drv}/${path}") (pathListForVersion lua.luaversion);
getLuaPath = drv: getPath drv getLuaPathList;
getLuaCPath = drv: getPath drv getLuaCPathList;
#define build lua package function
buildLuaPackage = callPackage ../development/lua-modules/generic {
inherit lua writeText;
};
inherit toLuaModule lua-setup-hook;
inherit buildLuarocksPackage buildLuaApplication;
inherit requiredLuaModules luaOlder luaAtLeast
2019-02-14 05:32:04 +00:00
isLua51 isLua52 isLua53 isLuaJIT lua callPackage;
# wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH
wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix {
inherit lua; inherit (pkgs) makeSetupHook makeWrapper;
};
luarocks = callPackage ../development/tools/misc/luarocks {
inherit lua;
};
luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { };
2017-09-24 15:02:02 +01:00
luxio = buildLuaPackage rec {
name = "luxio-${version}";
version = "13";
2017-09-24 15:02:02 +01:00
src = fetchurl {
url = "https://git.gitano.org.uk/luxio.git/snapshot/luxio-luxio-13.tar.bz2";
sha256 = "1hvwslc25q7k82rxk461zr1a2041nxg7sn3sw3w0y5jxf0giz2pz";
};
2017-09-24 15:44:43 +01:00
nativeBuildInputs = [ which pkgconfig ];
2017-09-24 15:44:43 +01:00
postPatch = ''
patchShebangs .
'';
2017-09-24 15:02:02 +01:00
preBuild = ''
makeFlagsArray=(
INST_LIBDIR="$out/lib/lua/${lua.luaversion}"
INST_LUADIR="$out/share/lua/${lua.luaversion}"
LUA_BINDIR="$out/bin"
2017-09-24 15:44:43 +01:00
INSTALL=install
2017-09-24 15:02:02 +01:00
);
'';
meta = with stdenv.lib; {
description = "Lightweight UNIX I/O and POSIX binding for Lua";
homepage = "https://www.gitano.org.uk/luxio/";
license = licenses.mit;
maintainers = with maintainers; [ richardipsum ];
platforms = platforms.unix;
};
2017-09-24 15:02:02 +01:00
};
2019-09-28 14:31:39 +01:00
pulseaudio = buildLuaPackage rec {
pname = "pulseaudio";
2019-11-09 09:31:05 +00:00
version = "0.2";
2019-09-28 14:31:39 +01:00
name = "pulseaudio-${version}";
src = fetchFromGitHub {
owner = "doronbehar";
repo = "lua-pulseaudio";
rev = "v${version}";
2019-11-09 09:31:05 +00:00
sha256 = "140y1m6k798c4w7xfl0zb0a4ffjz6i1722bgkdcdg8g76hr5r8ys";
2019-09-28 14:31:39 +01:00
};
disabled = (luaOlder "5.1") || (luaAtLeast "5.5");
buildInputs = [ pkgs.libpulseaudio ];
propagatedBuildInputs = [ lua ];
nativeBuildInputs = [ pkgs.pulseaudio pkgconfig ];
makeFlags = [
"INST_LIBDIR=${placeholder "out"}/lib/lua/${lua.luaversion}"
"INST_LUADIR=${placeholder "out"}/share/lua/${lua.luaversion}"
"LUA_BINDIR=${placeholder "out"}/bin"
];
preBuild = ''
mkdir -p ${placeholder "out"}/lib/lua/${lua.luaversion}
'';
meta = with stdenv.lib; {
homepage = "https://github.com/doronbehar/lua-pulseaudio";
description = "Libpulse Lua bindings";
maintainers = with maintainers; [ doronbehar ];
license = licenses.lgpl21;
};
};
vicious = toLuaModule(stdenv.mkDerivation rec {
pname = "vicious";
2017-12-22 09:06:27 +00:00
version = "2.3.1";
src = fetchFromGitHub {
owner = "Mic92";
repo = "vicious";
rev = "v${version}";
2017-12-22 09:06:27 +00:00
sha256 = "1yzhjn8rsvjjsfycdc993ms6jy2j5jh7x3r2ax6g02z5n0anvnbx";
};
buildInputs = [ lua ];
installPhase = ''
mkdir -p $out/lib/lua/${lua.luaversion}/
cp -r . $out/lib/lua/${lua.luaversion}/vicious/
printf "package.path = '$out/lib/lua/${lua.luaversion}/?/init.lua;' .. package.path\nreturn require((...) .. '.init')\n" > $out/lib/lua/${lua.luaversion}/vicious.lua
'';
meta = with stdenv.lib; {
2017-12-22 09:06:27 +00:00
description = "A modular widget library for the awesome window manager";
homepage = https://github.com/Mic92/vicious;
license = licenses.gpl2;
maintainers = with maintainers; [ makefu mic92 ];
platforms = platforms.linux;
};
});
});
in packages