Merge pull request #136615 from teto/lua-flat

Various lua changes/cleanup
This commit is contained in:
Matthieu Coudron 2021-09-12 18:08:53 +02:00 committed by GitHub
commit ab9c7819fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 213 additions and 140 deletions

View file

@ -1150,6 +1150,13 @@ Superuser created successfully.
other and share data. other and share data.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
<literal>lua</literal> and <literal>luajit</literal>
interpreters have been patched to avoid looking into /usr/lib
directories, thus increasing the purity of the build.
</para>
</listitem>
</itemizedlist> </itemizedlist>
</section> </section>
</section> </section>

View file

@ -328,3 +328,6 @@ To be able to access the web UI this port needs to be opened in the firewall.
- `rofi` has been updated from '1.6.1' to '1.7.0', one important thing is the removal of the old xresources based configuration setup. Read more [in rofi's changelog](https://github.com/davatorium/rofi/blob/cb12e6fc058f4a0f4f/Changelog#L1). - `rofi` has been updated from '1.6.1' to '1.7.0', one important thing is the removal of the old xresources based configuration setup. Read more [in rofi's changelog](https://github.com/davatorium/rofi/blob/cb12e6fc058f4a0f4f/Changelog#L1).
- ipfs now defaults to not listening on you local network. This setting was change as server providers won't accept port scanning on their private network. If you have several ipfs instances running on a network you own, feel free to change the setting `ipfs.localDiscovery = true;`. localDiscovery enables different instances to discover each other and share data. - ipfs now defaults to not listening on you local network. This setting was change as server providers won't accept port scanning on their private network. If you have several ipfs instances running on a network you own, feel free to change the setting `ipfs.localDiscovery = true;`. localDiscovery enables different instances to discover each other and share data.
- `lua` and `luajit` interpreters have been patched to avoid looking into /usr/lib
directories, thus increasing the purity of the build.

View file

@ -133,7 +133,7 @@ rec {
configure.pathogen.pluginNames = [ "vim-nix" ]; configure.pathogen.pluginNames = [ "vim-nix" ];
}; };
nvimWithLuaPackages = wrapNeovim2 "with-lua-packages" (makeNeovimConfig { nvimWithLuaPackages = wrapNeovim2 "-with-lua-packages" (makeNeovimConfig {
extraLuaPackages = ps: [ps.mpack]; extraLuaPackages = ps: [ps.mpack];
customRC = '' customRC = ''
lua require("mpack") lua require("mpack")
@ -141,6 +141,7 @@ rec {
}); });
nvim_with_lua_packages = runTest nvimWithLuaPackages '' nvim_with_lua_packages = runTest nvimWithLuaPackages ''
export HOME=$TMPDIR
${nvimWithLuaPackages}/bin/nvim -i NONE --noplugin -es ${nvimWithLuaPackages}/bin/nvim -i NONE --noplugin -es
''; '';
}) })

View file

@ -78,8 +78,7 @@ let
++ (extraPython3Packages ps) ++ (extraPython3Packages ps)
++ (lib.concatMap (f: f ps) pluginPython3Packages)); ++ (lib.concatMap (f: f ps) pluginPython3Packages));
lua = neovim-unwrapped.lua; luaEnv = neovim-unwrapped.lua.withPackages(extraLuaPackages);
luaEnv = lua.withPackages(ps: extraLuaPackages ps);
# Mapping a boolean argument to a key that tells us whether to add or not to # Mapping a boolean argument to a key that tells us whether to add or not to
# add to nvim's 'embedded rc' this: # add to nvim's 'embedded rc' this:
@ -115,8 +114,8 @@ let
] ++ lib.optionals (binPath != "") [ ] ++ lib.optionals (binPath != "") [
"--suffix" "PATH" ":" binPath "--suffix" "PATH" ":" binPath
] ++ lib.optionals (luaEnv != null) [ ] ++ lib.optionals (luaEnv != null) [
"--prefix" "LUA_PATH" ";" "${luaEnv}/share/lua/${lua.luaversion}/?.lua" "--prefix" "LUA_PATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaPathAbsStr luaEnv)
"--prefix" "LUA_CPATH" ";" "${luaEnv}/lib/lua/${lua.luaversion}/?.so" "--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaCPathAbsStr luaEnv)
]; ];

View file

@ -1,8 +1,11 @@
{ lib, stdenv, fetchFromGitHub, pkg-config, makeWrapper, makeDesktopItem { lib, stdenv, fetchFromGitHub, pkg-config, makeWrapper, makeDesktopItem
, ncurses, libtermkey, lpeg, lua , ncurses, libtermkey, lua
, acl ? null, libselinux ? null , acl ? null, libselinux ? null
}: }:
let
luaEnv = lua.withPackages(ps: [ ps.lpeg ]);
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "vis"; pname = "vis";
version = "0.7"; version = "0.7";
@ -19,8 +22,7 @@ stdenv.mkDerivation rec {
buildInputs = [ buildInputs = [
ncurses ncurses
libtermkey libtermkey
lua luaEnv
lpeg
] ++ lib.optionals stdenv.isLinux [ ] ++ lib.optionals stdenv.isLinux [
acl acl
libselinux libselinux
@ -30,16 +32,13 @@ stdenv.mkDerivation rec {
patchShebangs ./configure patchShebangs ./configure
''; '';
LUA_CPATH="${lpeg}/lib/lua/${lua.luaversion}/?.so;";
LUA_PATH="${lpeg}/share/lua/${lua.luaversion}/?.lua";
postInstall = '' postInstall = ''
mkdir -p "$out/share/applications" mkdir -p "$out/share/applications"
cp $desktopItem/share/applications/* $out/share/applications cp $desktopItem/share/applications/* $out/share/applications
echo wrapping $out/bin/vis with runtime environment echo wrapping $out/bin/vis with runtime environment
wrapProgram $out/bin/vis \ wrapProgram $out/bin/vis \
--prefix LUA_CPATH ';' "${lpeg}/lib/lua/${lua.luaversion}/?.so" \ --prefix LUA_CPATH ';' "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \
--prefix LUA_PATH ';' "${lpeg}/share/lua/${lua.luaversion}/?.lua" \ --prefix LUA_PATH ';' "${luaEnv}/share/lua/${lua.luaversion}/?.lua" \
--prefix VIS_PATH : "\$HOME/.config:$out/share/vis" --prefix VIS_PATH : "\$HOME/.config:$out/share/vis"
''; '';

View file

@ -1,4 +1,4 @@
{ lib, stdenv, fetchFromGitHub, luaPackages, cairo, librsvg, cmake, imagemagick, pkg-config, gdk-pixbuf { lib, stdenv, fetchFromGitHub, lua, cairo, librsvg, cmake, imagemagick, pkg-config, gdk-pixbuf
, xorg, libstartup_notification, libxdg_basedir, libpthreadstubs , xorg, libstartup_notification, libxdg_basedir, libpthreadstubs
, xcb-util-cursor, makeWrapper, pango, gobject-introspection , xcb-util-cursor, makeWrapper, pango, gobject-introspection
, which, dbus, nettools, git, doxygen , which, dbus, nettools, git, doxygen
@ -12,10 +12,11 @@
# needed for beautiful.gtk to work # needed for beautiful.gtk to work
assert gtk3Support -> gtk3 != null; assert gtk3Support -> gtk3 != null;
let
luaEnv = lua.withPackages(ps: [ ps.lgi ps.ldoc ]);
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
lgi = luaPackages.lgi;
lua = luaPackages.lua;
ldoc = luaPackages.ldoc;
pname = "awesome"; pname = "awesome";
version = "4.3"; version = "4.3";
@ -35,7 +36,6 @@ stdenv.mkDerivation rec {
xmlto docbook_xml_dtd_45 xmlto docbook_xml_dtd_45
docbook_xsl findXMLCatalogs docbook_xsl findXMLCatalogs
asciidoctor asciidoctor
ldoc
]; ];
outputs = [ "out" "doc" ]; outputs = [ "out" "doc" ];
@ -44,7 +44,7 @@ stdenv.mkDerivation rec {
propagatedUserEnvPkgs = [ hicolor-icon-theme ]; propagatedUserEnvPkgs = [ hicolor-icon-theme ];
buildInputs = [ cairo librsvg dbus gdk-pixbuf gobject-introspection buildInputs = [ cairo librsvg dbus gdk-pixbuf gobject-introspection
git lgi libpthreadstubs libstartup_notification git luaEnv libpthreadstubs libstartup_notification
libxdg_basedir lua nettools pango xcb-util-cursor libxdg_basedir lua nettools pango xcb-util-cursor
xorg.libXau xorg.libXdmcp xorg.libxcb xorg.libxshmfence xorg.libXau xorg.libXdmcp xorg.libxcb xorg.libxshmfence
xorg.xcbutil xorg.xcbutilimage xorg.xcbutilkeysyms xorg.xcbutil xorg.xcbutilimage xorg.xcbutilkeysyms
@ -55,14 +55,14 @@ stdenv.mkDerivation rec {
cmakeFlags = [ cmakeFlags = [
#"-DGENERATE_MANPAGES=ON" #"-DGENERATE_MANPAGES=ON"
"-DOVERRIDE_VERSION=${version}" "-DOVERRIDE_VERSION=${version}"
] ++ lib.optional luaPackages.isLuaJIT "-DLUA_LIBRARY=${lua}/lib/libluajit-5.1.so" ] ++ lib.optional lua.pkgs.isLuaJIT "-DLUA_LIBRARY=${lua}/lib/libluajit-5.1.so"
; ;
GI_TYPELIB_PATH = "${pango.out}/lib/girepository-1.0"; GI_TYPELIB_PATH = "${pango.out}/lib/girepository-1.0";
# LUA_CPATH and LUA_PATH are used only for *building*, see the --search flags # LUA_CPATH and LUA_PATH are used only for *building*, see the --search flags
# below for how awesome finds the libraries it needs at runtime. # below for how awesome finds the libraries it needs at runtime.
LUA_CPATH = "${lgi}/lib/lua/${lua.luaversion}/?.so"; LUA_CPATH = "${luaEnv}/lib/lua/${lua.luaversion}/?.so";
LUA_PATH = "${lgi}/share/lua/${lua.luaversion}/?.lua;;"; LUA_PATH = "${luaEnv}/share/lua/${lua.luaversion}/?.lua;;";
postInstall = '' postInstall = ''
# Don't use wrapProgram or the wrapper will duplicate the --search # Don't use wrapProgram or the wrapper will duplicate the --search
@ -70,8 +70,8 @@ stdenv.mkDerivation rec {
mv "$out/bin/awesome" "$out/bin/.awesome-wrapped" mv "$out/bin/awesome" "$out/bin/.awesome-wrapped"
makeWrapper "$out/bin/.awesome-wrapped" "$out/bin/awesome" \ makeWrapper "$out/bin/.awesome-wrapped" "$out/bin/awesome" \
--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \ --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
--add-flags '--search ${lgi}/lib/lua/${lua.luaversion}' \ --add-flags '--search ${luaEnv}/lib/lua/${lua.luaversion}' \
--add-flags '--search ${lgi}/share/lua/${lua.luaversion}' \ --add-flags '--search ${luaEnv}/share/lua/${lua.luaversion}' \
--prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH"
wrapProgram $out/bin/awesome-client \ wrapProgram $out/bin/awesome-client \

View file

@ -238,7 +238,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
inherit externalDeps; inherit externalDeps;
} // passthru; } // passthru;
meta = with lib.maintainers; { meta = {
platforms = lua.meta.platforms; platforms = lua.meta.platforms;
# add extra maintainer(s) to every package # add extra maintainer(s) to every package
maintainers = (meta.maintainers or []) ++ [ ]; maintainers = (meta.maintainers or []) ++ [ ];

View file

@ -1,7 +1,8 @@
{ lib, stdenv, fetchurl, readline { lib, stdenv, fetchurl, readline
, compat ? false , compat ? false
, callPackage , callPackage
, packageOverrides ? (self: super: {}) , makeWrapper
, packageOverrides ? (final: prev: {})
, sourceVersion , sourceVersion
, hash , hash
, patches ? [] , patches ? []
@ -10,7 +11,10 @@
, staticOnly ? stdenv.hostPlatform.isStatic , staticOnly ? stdenv.hostPlatform.isStatic
}: }:
let let
luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;}; luaPackages = callPackage ../../lua-modules {
lua = self;
overrides = packageOverrides;
};
plat = if stdenv.isLinux then "linux" plat = if stdenv.isLinux then "linux"
else if stdenv.isDarwin then "macosx" else if stdenv.isDarwin then "macosx"
@ -31,15 +35,26 @@ self = stdenv.mkDerivation rec {
sha256 = hash; sha256 = hash;
}; };
LuaPathSearchPaths = luaPackages.getLuaPathList luaversion; LuaPathSearchPaths = luaPackages.lib.luaPathList;
LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion; LuaCPathSearchPaths = luaPackages.lib.luaCPathList;
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths; setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ readline ]; buildInputs = [ readline ];
inherit patches; inherit patches;
postPatch = lib.optionalString (!stdenv.isDarwin && !staticOnly) '' # we can't pass flags to the lua makefile because for portability, everything is hardcoded
postPatch = ''
{
echo -e '
#undef LUA_PATH_DEFAULT
#define LUA_PATH_DEFAULT "./share/lua/${luaversion}/?.lua;./?.lua;./?/init.lua"
#undef LUA_CPATH_DEFAULT
#define LUA_CPATH_DEFAULT "./lib/lua/${luaversion}/?.so;./?.so;./lib/lua/${luaversion}/loadall.so"
'
} >> src/luaconf.h
'' + lib.optionalString (!stdenv.isDarwin && !staticOnly) ''
# Add a target for a shared library to the Makefile. # Add a target for a shared library to the Makefile.
sed -e '1s/^/LUA_SO = liblua.so/' \ sed -e '1s/^/LUA_SO = liblua.so/' \
-e 's/ALL_T *= */&$(LUA_SO) /' \ -e 's/ALL_T *= */&$(LUA_SO) /' \

View file

@ -4,8 +4,6 @@
, makeWrapper , makeWrapper
}: }:
with lib;
# defined in trivial-builders.nix # defined in trivial-builders.nix
# imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput # imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput
makeSetupHook { makeSetupHook {
@ -14,6 +12,5 @@ makeSetupHook {
substitutions.lua = lua; substitutions.lua = lua;
substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
} ./wrap.sh } ./wrap.sh

View file

@ -11,13 +11,18 @@
let let
env = let env = let
paths = requiredLuaModules (extraLibs ++ [ lua ] ); paths = requiredLuaModules (extraLibs ++ [ lua ] );
in (buildEnv { in buildEnv {
name = "${lua.name}-env"; name = "${lua.name}-env";
inherit paths; inherit paths;
inherit ignoreCollisions; inherit ignoreCollisions;
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall; extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
nativeBuildInputs = [
makeWrapper
(lua.pkgs.lua-setup-hook lua.LuaPathSearchPaths lua.LuaCPathSearchPaths)
];
# we create wrapper for the binaries in the different packages # we create wrapper for the binaries in the different packages
postBuild = '' postBuild = ''
if [ -L "$out/bin" ]; then if [ -L "$out/bin" ]; then
@ -37,7 +42,12 @@ let
rm -f "$out/bin/$prg" rm -f "$out/bin/$prg"
if [ -x "$prg" ]; then if [ -x "$prg" ]; then
nix_debug "Making wrapper $prg" nix_debug "Making wrapper $prg"
makeWrapper "$path/bin/$prg" "$out/bin/$prg" --suffix LUA_PATH ';' "$LUA_PATH" --suffix LUA_CPATH ';' "$LUA_CPATH" ${lib.concatStringsSep " " makeWrapperArgs} makeWrapper "$path/bin/$prg" "$out/bin/$prg" \
--set-default LUA_PATH ";;" \
--suffix LUA_PATH ';' "$LUA_PATH" \
--set-default LUA_CPATH ";;" \
--suffix LUA_CPATH ';' "$LUA_CPATH" \
${lib.concatStringsSep " " makeWrapperArgs}
fi fi
fi fi
done done
@ -62,8 +72,5 @@ let
''; '';
}; };
}; };
}).overrideAttrs (_: { };
# Add extra deps needed for postBuild hook.
nativeBuildInputs = [ makeWrapper lua ];
});
in env in env

View file

@ -10,7 +10,7 @@
, extraMeta ? { } , extraMeta ? { }
, callPackage , callPackage
, self , self
, packageOverrides ? (self: super: { }) , packageOverrides ? (final: prev: {})
, enableFFI ? true , enableFFI ? true
, enableJIT ? true , enableJIT ? true
, enableJITDebugModule ? enableJIT , enableJITDebugModule ? enableJIT
@ -62,6 +62,15 @@ stdenv.mkDerivation rec {
# passed by nixpkgs CC wrapper is insufficient on its own # passed by nixpkgs CC wrapper is insufficient on its own
substituteInPlace src/Makefile --replace "#CCDEBUG= -g" "CCDEBUG= -g" substituteInPlace src/Makefile --replace "#CCDEBUG= -g" "CCDEBUG= -g"
fi fi
{
echo -e '
#undef LUA_PATH_DEFAULT
#define LUA_PATH_DEFAULT "./share/lua/${luaversion}/?.lua;./?.lua;./?/init.lua"
#undef LUA_CPATH_DEFAULT
#define LUA_CPATH_DEFAULT "./lib/lua/${luaversion}/?.so;./?.so;./lib/lua/${luaversion}/loadall.so"
'
} >> src/luaconf.h
''; '';
configurePhase = false; configurePhase = false;
@ -88,15 +97,10 @@ stdenv.mkDerivation rec {
ln -s "$out"/bin/luajit-* "$out"/bin/luajit ln -s "$out"/bin/luajit-* "$out"/bin/luajit
''; '';
LuaPathSearchPaths = [ LuaPathSearchPaths = luaPackages.lib.luaPathList;
"lib/lua/${luaversion}/?.lua" LuaCPathSearchPaths = luaPackages.lib.luaCPathList;
"share/lua/${luaversion}/?.lua"
"share/lua/${luaversion}/?/init.lua" setupHook = luaPackages.lua-setup-hook luaPackages.lib.luaPathList luaPackages.lib.luaCPathList;
"lib/lua/${luaversion}/?/init.lua"
"share/${name}/?.lua"
];
LuaCPathSearchPaths = [ "lib/lua/${luaversion}/?.so" "share/lua/${luaversion}/?.so" ];
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
passthru = rec { passthru = rec {
buildEnv = callPackage ../lua-5/wrapper.nix { buildEnv = callPackage ../lua-5/wrapper.nix {

View file

@ -1,7 +1,7 @@
# inspired by pkgs/development/haskell-modules/default.nix # inspired by pkgs/development/haskell-modules/default.nix
{ pkgs, lib { pkgs, lib
, lua , lua
, overrides ? (self: super: {}) , overrides ? (final: prev: {})
}: }:
let let
@ -15,7 +15,7 @@ let
overridenPackages = import ./overrides.nix { inherit pkgs; }; overridenPackages = import ./overrides.nix { inherit pkgs; };
generatedPackages = if (builtins.pathExists ./generated-packages.nix) then generatedPackages = if (builtins.pathExists ./generated-packages.nix) then
pkgs.callPackage ./generated-packages.nix { } else (self: super: {}); pkgs.callPackage ./generated-packages.nix { } else (final: prev: {});
extensible-self = lib.makeExtensible extensible-self = lib.makeExtensible
(extends overrides (extends overrides
@ -24,7 +24,6 @@ let
initialPackages initialPackages
) )
) )
) );
;
in in
extensible-self extensible-self

View file

@ -0,0 +1,63 @@
{ pkgs, lib, lua }:
let
requiredLuaModules = drvs: with lib; let
modules = filter hasLuaModule drvs;
in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules));
# Check whether a derivation provides a lua module.
hasLuaModule = drv: drv ? luaModule;
in
rec {
inherit hasLuaModule requiredLuaModules;
luaPathList = [
"share/lua/${lua.luaversion}/?.lua"
"share/lua/${lua.luaversion}/?/init.lua"
];
luaCPathList = [
"lib/lua/${lua.luaversion}/?.so"
];
/* generate paths without a prefix
*/
luaPathRelStr = lib.concatStringsSep ";" luaPathList;
luaCPathRelStr = lib.concatStringsSep ";" luaCPathList;
/* generate LUA_(C)PATH value for a specific derivation, i.e., with absolute paths
*/
genLuaPathAbsStr = drv: lib.concatMapStringsSep ";" (x: "${drv}/${x}") luaPathList;
genLuaCPathAbsStr = drv: lib.concatMapStringsSep ";" (x: "${drv}/${x}") luaCPathList;
/* Generate a LUA_PATH with absolute paths
*/
# genLuaPathAbs = drv:
# lib.concatStringsSep ";" (map (x: "${drv}/x") luaPathList);
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";
/* generates the relative path towards the folder where
seems stable even when using lua_modules_path = ""
Example:
getDataFolder luaPackages.stdlib
=> stdlib-41.2.2-1-rocks/stdlib/41.2.2-1/doc
*/
getDataFolder = drv:
"${drv.pname}-${drv.version}-rocks/${drv.pname}/${drv.version}";
/* Convert derivation to a lua module.
so that luaRequireModules can be run later
*/
toLuaModule = drv:
drv.overrideAttrs( oldAttrs: {
# Use passthru in order to prevent rebuilds when possible.
passthru = (oldAttrs.passthru or {}) // {
luaModule = lua;
requiredLuaModules = requiredLuaModules drv.propagatedBuildInputs;
};
});
}

View file

@ -363,6 +363,12 @@ with super;
''; '';
}); });
# TODO just while testing, remove afterwards
# toVimPlugin should do it instead
gitsigns-nvim = super.gitsigns-nvim.overrideAttrs(oa: {
nativeBuildInputs = oa.nativeBuildInputs or [] ++ [ pkgs.vimUtils.vimGenDocHook ];
});
# aliases # aliases
cjson = super.lua-cjson; cjson = super.lua-cjson;
} }

View file

@ -2,7 +2,9 @@
, boost, libGLU, lua, cmake, which, pkg-config, }: , boost, libGLU, lua, cmake, which, pkg-config, }:
let let
luaEnv = lua.withPackages(ps: with ps; [ luazip luafilesystem lrexlib-pcre luasql-sqlite3 lua-yajl luautf8 ]); luaEnv = lua.withPackages(ps: with ps; [
luazip luafilesystem lrexlib-pcre luasql-sqlite3 lua-yajl luautf8
]);
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
pname = "mudlet"; pname = "mudlet";
@ -39,8 +41,6 @@ stdenv.mkDerivation rec {
cp -r ../mudlet.png $out/share/pixmaps/ cp -r ../mudlet.png $out/share/pixmaps/
makeQtWrapper $out/mudlet $out/bin/mudlet \ makeQtWrapper $out/mudlet $out/bin/mudlet \
--set LUA_CPATH "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \
--prefix LUA_PATH : "$NIX_LUA_PATH" \
--prefix LD_LIBRARY_PATH : "${libsForQt5.qtkeychain}/lib/" \ --prefix LD_LIBRARY_PATH : "${libsForQt5.qtkeychain}/lib/" \
--run "cd $out"; --run "cd $out";
''; '';

View file

@ -1,19 +1,24 @@
{ stdenv, fetchurl, lib, libidn, openssl, makeWrapper, fetchhg { stdenv, fetchurl, lib, libidn, openssl, makeWrapper, fetchhg
, lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop , lua
, nixosTests , nixosTests
, withLibevent ? true, luaevent ? null , withLibevent ? true
, withDBI ? true, luadbi ? null , withDBI ? true
# use withExtraLibs to add additional dependencies of community modules # use withExtraLibs to add additional dependencies of community modules
, withExtraLibs ? [ ] , withExtraLibs ? [ ]
, withOnlyInstalledCommunityModules ? [ ] , withOnlyInstalledCommunityModules ? [ ]
, withCommunityModules ? [ ] }: , withCommunityModules ? [ ] }:
assert withLibevent -> luaevent != null;
assert withDBI -> luadbi != null;
with lib; with lib;
let
luaEnv = lua.withPackages(p: with p; [
luasocket luasec luaexpat luafilesystem luabitop luadbi-sqlite3
]
++ lib.optional withLibevent p.luaevent
++ lib.optional withDBI p.luadbi
);
in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "0.11.10"; # also update communityModules version = "0.11.10"; # also update communityModules
pname = "prosody"; pname = "prosody";
@ -41,28 +46,24 @@ stdenv.mkDerivation rec {
sha256 = "02gj1b8sdmdvymsdmjpq47zrl7sg578jcdxbbq18s44f3njmc9q1"; sha256 = "02gj1b8sdmdvymsdmjpq47zrl7sg578jcdxbbq18s44f3njmc9q1";
}; };
nativeBuildInputs = [ makeWrapper ];
buildInputs = [ buildInputs = [
lua5 makeWrapper libidn openssl luaEnv libidn openssl
] ]
# Lua libraries
++ [
luasocket luasec luaexpat luafilesystem luabitop
]
++ optional withLibevent luaevent
++ optional withDBI luadbi
++ withExtraLibs; ++ withExtraLibs;
configureFlags = [ configureFlags = [
"--ostype=linux" "--ostype=linux"
"--with-lua-include=${lua5}/include" "--with-lua-include=${luaEnv}/include"
"--with-lua=${lua5}" "--with-lua=${luaEnv}"
]; ];
postBuild = '' postBuild = ''
make -C tools/migration make -C tools/migration
''; '';
# the wrapping should go away once lua hook is fixed
postInstall = '' postInstall = ''
${concatMapStringsSep "\n" (module: '' ${concatMapStringsSep "\n" (module: ''
cp -r $communityModules/mod_${module} $out/lib/prosody/modules/ cp -r $communityModules/mod_${module} $out/lib/prosody/modules/

View file

@ -19950,9 +19950,8 @@ with pkgs;
prosody = callPackage ../servers/xmpp/prosody { prosody = callPackage ../servers/xmpp/prosody {
# _compat can probably be removed on next minor version after 0.10.0 # _compat can probably be removed on next minor version after 0.10.0
lua5 = lua5_2_compat; lua = lua5_2_compat;
withExtraLibs = [ luaPackages.luadbi-sqlite3 ]; withExtraLibs = [];
inherit (lua52Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luadbi;
}; };
biboumi = callPackage ../servers/xmpp/biboumi { }; biboumi = callPackage ../servers/xmpp/biboumi { };
@ -28277,9 +28276,7 @@ with pkgs;
neovim-remote = callPackage ../applications/editors/neovim/neovim-remote.nix { }; neovim-remote = callPackage ../applications/editors/neovim/neovim-remote.nix { };
vis = callPackage ../applications/editors/vis { vis = callPackage ../applications/editors/vis { };
inherit (lua52Packages) lpeg;
};
viw = callPackage ../applications/editors/viw { }; viw = callPackage ../applications/editors/viw { };

View file

@ -18,85 +18,60 @@ let
packages = ( self: packages = ( self:
let 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 { }; # a function of lua_path / lua_cpath
lua-setup-hook = callPackage ../development/interpreters/lua-5/setup-hook.nix {
# Check whether a derivation provides a lua module. inherit lib;
hasLuaModule = drv: drv ? luaModule ; };
callPackage = pkgs.newScope self; callPackage = pkgs.newScope self;
requiredLuaModules = drvs: with 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 ); buildLuaApplication = args: buildLuarocksPackage ({namePrefix="";} // args );
buildLuarocksPackage = with pkgs.lib; makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix { buildLuarocksPackage = lib.makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix {
inherit toLuaModule;
inherit lua; inherit lua;
inherit (pkgs) lib;
inherit (luaLib) toLuaModule;
}); });
in
with self; {
getLuaPathList = majorVersion: [ luaLib = import ../development/lua-modules/lib.nix {
"share/lua/${majorVersion}/?.lua" inherit (pkgs) lib;
"share/lua/${majorVersion}/?/init.lua" inherit pkgs 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 #define build lua package function
buildLuaPackage = callPackage ../development/lua-modules/generic { buildLuaPackage = callPackage ../development/lua-modules/generic {
inherit lua writeText; inherit writeText;
}; };
getPath = drv: pathListForVersion:
lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion;
inherit toLuaModule hasLuaModule lua-setup-hook; in
inherit buildLuarocksPackage buildLuaApplication; {
inherit requiredLuaModules luaOlder luaAtLeast # helper functions for dealing with LUA_PATH and LUA_CPATH
isLua51 isLua52 isLua53 isLuaJIT lua callPackage; lib = luaLib;
getLuaPath = drv: luaLib.getPath drv (luaLib.luaPathList lua.luaversion) ;
getLuaCPath = drv: luaLib.getPath drv (luaLib.luaCPathList lua.luaversion) ;
inherit lua lua-setup-hook callPackage;
inherit buildLuaPackage buildLuarocksPackage buildLuaApplication;
inherit (luaLib) luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT
requiredLuaModules toLuaModule hasLuaModule;
# wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH
wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix {
inherit lua; inherit (pkgs) makeSetupHook makeWrapper; inherit lua lib;
inherit (pkgs) makeSetupHook makeWrapper;
}; };
luarocks = callPackage ../development/tools/misc/luarocks { luarocks = callPackage ../development/tools/misc/luarocks {
inherit lua; inherit lua lib;
}; };
# a fork of luarocks used to generate nix lua derivations from rockspecs
luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { };
luxio = buildLuaPackage { luxio = buildLuaPackage {
@ -132,7 +107,7 @@ with self; {
}; };
}; };
vicious = toLuaModule(stdenv.mkDerivation rec { vicious = luaLib.toLuaModule( stdenv.mkDerivation rec {
pname = "vicious"; pname = "vicious";
version = "2.5.0"; version = "2.5.0";