Merge pull request #136615 from teto/lua-flat

Various lua changes/cleanup

authored by

Matthieu Coudron and committed by
GitHub
ab9c7819 3ca823aa

+213 -140
+7
nixos/doc/manual/from_md/release-notes/rl-2111.section.xml
··· 1150 1150 other and share data. 1151 1151 </para> 1152 1152 </listitem> 1153 + <listitem> 1154 + <para> 1155 + <literal>lua</literal> and <literal>luajit</literal> 1156 + interpreters have been patched to avoid looking into /usr/lib 1157 + directories, thus increasing the purity of the build. 1158 + </para> 1159 + </listitem> 1153 1160 </itemizedlist> 1154 1161 </section> 1155 1162 </section>
+3
nixos/doc/manual/release-notes/rl-2111.section.md
··· 328 328 - `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). 329 329 330 330 - 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. 331 + 332 + - `lua` and `luajit` interpreters have been patched to avoid looking into /usr/lib 333 + directories, thus increasing the purity of the build.
+2 -1
pkgs/applications/editors/neovim/tests.nix
··· 133 133 configure.pathogen.pluginNames = [ "vim-nix" ]; 134 134 }; 135 135 136 - nvimWithLuaPackages = wrapNeovim2 "with-lua-packages" (makeNeovimConfig { 136 + nvimWithLuaPackages = wrapNeovim2 "-with-lua-packages" (makeNeovimConfig { 137 137 extraLuaPackages = ps: [ps.mpack]; 138 138 customRC = '' 139 139 lua require("mpack") ··· 141 141 }); 142 142 143 143 nvim_with_lua_packages = runTest nvimWithLuaPackages '' 144 + export HOME=$TMPDIR 144 145 ${nvimWithLuaPackages}/bin/nvim -i NONE --noplugin -es 145 146 ''; 146 147 })
+3 -4
pkgs/applications/editors/neovim/utils.nix
··· 78 78 ++ (extraPython3Packages ps) 79 79 ++ (lib.concatMap (f: f ps) pluginPython3Packages)); 80 80 81 - lua = neovim-unwrapped.lua; 82 - luaEnv = lua.withPackages(ps: extraLuaPackages ps); 81 + luaEnv = neovim-unwrapped.lua.withPackages(extraLuaPackages); 83 82 84 83 # Mapping a boolean argument to a key that tells us whether to add or not to 85 84 # add to nvim's 'embedded rc' this: ··· 115 114 ] ++ lib.optionals (binPath != "") [ 116 115 "--suffix" "PATH" ":" binPath 117 116 ] ++ lib.optionals (luaEnv != null) [ 118 - "--prefix" "LUA_PATH" ";" "${luaEnv}/share/lua/${lua.luaversion}/?.lua" 119 - "--prefix" "LUA_CPATH" ";" "${luaEnv}/lib/lua/${lua.luaversion}/?.so" 117 + "--prefix" "LUA_PATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaPathAbsStr luaEnv) 118 + "--prefix" "LUA_CPATH" ";" (neovim-unwrapped.lua.pkgs.lib.genLuaCPathAbsStr luaEnv) 120 119 ]; 121 120 122 121
+7 -8
pkgs/applications/editors/vis/default.nix
··· 1 1 { lib, stdenv, fetchFromGitHub, pkg-config, makeWrapper, makeDesktopItem 2 - , ncurses, libtermkey, lpeg, lua 2 + , ncurses, libtermkey, lua 3 3 , acl ? null, libselinux ? null 4 4 }: 5 5 6 + let 7 + luaEnv = lua.withPackages(ps: [ ps.lpeg ]); 8 + in 6 9 stdenv.mkDerivation rec { 7 10 pname = "vis"; 8 11 version = "0.7"; ··· 19 22 buildInputs = [ 20 23 ncurses 21 24 libtermkey 22 - lua 23 - lpeg 25 + luaEnv 24 26 ] ++ lib.optionals stdenv.isLinux [ 25 27 acl 26 28 libselinux ··· 30 32 patchShebangs ./configure 31 33 ''; 32 34 33 - LUA_CPATH="${lpeg}/lib/lua/${lua.luaversion}/?.so;"; 34 - LUA_PATH="${lpeg}/share/lua/${lua.luaversion}/?.lua"; 35 - 36 35 postInstall = '' 37 36 mkdir -p "$out/share/applications" 38 37 cp $desktopItem/share/applications/* $out/share/applications 39 38 echo wrapping $out/bin/vis with runtime environment 40 39 wrapProgram $out/bin/vis \ 41 - --prefix LUA_CPATH ';' "${lpeg}/lib/lua/${lua.luaversion}/?.so" \ 42 - --prefix LUA_PATH ';' "${lpeg}/share/lua/${lua.luaversion}/?.lua" \ 40 + --prefix LUA_CPATH ';' "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \ 41 + --prefix LUA_PATH ';' "${luaEnv}/share/lua/${lua.luaversion}/?.lua" \ 43 42 --prefix VIS_PATH : "\$HOME/.config:$out/share/vis" 44 43 ''; 45 44
+11 -11
pkgs/applications/window-managers/awesome/default.nix
··· 1 - { lib, stdenv, fetchFromGitHub, luaPackages, cairo, librsvg, cmake, imagemagick, pkg-config, gdk-pixbuf 1 + { lib, stdenv, fetchFromGitHub, lua, cairo, librsvg, cmake, imagemagick, pkg-config, gdk-pixbuf 2 2 , xorg, libstartup_notification, libxdg_basedir, libpthreadstubs 3 3 , xcb-util-cursor, makeWrapper, pango, gobject-introspection 4 4 , which, dbus, nettools, git, doxygen ··· 11 11 12 12 # needed for beautiful.gtk to work 13 13 assert gtk3Support -> gtk3 != null; 14 + 15 + let 16 + luaEnv = lua.withPackages(ps: [ ps.lgi ps.ldoc ]); 17 + in 14 18 15 19 stdenv.mkDerivation rec { 16 - lgi = luaPackages.lgi; 17 - lua = luaPackages.lua; 18 - ldoc = luaPackages.ldoc; 19 20 pname = "awesome"; 20 21 version = "4.3"; 21 22 ··· 35 36 xmlto docbook_xml_dtd_45 36 37 docbook_xsl findXMLCatalogs 37 38 asciidoctor 38 - ldoc 39 39 ]; 40 40 41 41 outputs = [ "out" "doc" ]; ··· 44 44 45 45 propagatedUserEnvPkgs = [ hicolor-icon-theme ]; 46 46 buildInputs = [ cairo librsvg dbus gdk-pixbuf gobject-introspection 47 - git lgi libpthreadstubs libstartup_notification 47 + git luaEnv libpthreadstubs libstartup_notification 48 48 libxdg_basedir lua nettools pango xcb-util-cursor 49 49 xorg.libXau xorg.libXdmcp xorg.libxcb xorg.libxshmfence 50 50 xorg.xcbutil xorg.xcbutilimage xorg.xcbutilkeysyms ··· 55 55 cmakeFlags = [ 56 56 #"-DGENERATE_MANPAGES=ON" 57 57 "-DOVERRIDE_VERSION=${version}" 58 - ] ++ lib.optional luaPackages.isLuaJIT "-DLUA_LIBRARY=${lua}/lib/libluajit-5.1.so" 58 + ] ++ lib.optional lua.pkgs.isLuaJIT "-DLUA_LIBRARY=${lua}/lib/libluajit-5.1.so" 59 59 ; 60 60 61 61 GI_TYPELIB_PATH = "${pango.out}/lib/girepository-1.0"; 62 62 # LUA_CPATH and LUA_PATH are used only for *building*, see the --search flags 63 63 # below for how awesome finds the libraries it needs at runtime. 64 - LUA_CPATH = "${lgi}/lib/lua/${lua.luaversion}/?.so"; 65 - LUA_PATH = "${lgi}/share/lua/${lua.luaversion}/?.lua;;"; 64 + LUA_CPATH = "${luaEnv}/lib/lua/${lua.luaversion}/?.so"; 65 + LUA_PATH = "${luaEnv}/share/lua/${lua.luaversion}/?.lua;;"; 66 66 67 67 postInstall = '' 68 68 # Don't use wrapProgram or the wrapper will duplicate the --search ··· 70 70 mv "$out/bin/awesome" "$out/bin/.awesome-wrapped" 71 71 makeWrapper "$out/bin/.awesome-wrapped" "$out/bin/awesome" \ 72 72 --set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \ 73 - --add-flags '--search ${lgi}/lib/lua/${lua.luaversion}' \ 74 - --add-flags '--search ${lgi}/share/lua/${lua.luaversion}' \ 73 + --add-flags '--search ${luaEnv}/lib/lua/${lua.luaversion}' \ 74 + --add-flags '--search ${luaEnv}/share/lua/${lua.luaversion}' \ 75 75 --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" 76 76 77 77 wrapProgram $out/bin/awesome-client \
+1 -1
pkgs/development/interpreters/lua-5/build-lua-package.nix
··· 238 238 inherit externalDeps; 239 239 } // passthru; 240 240 241 - meta = with lib.maintainers; { 241 + meta = { 242 242 platforms = lua.meta.platforms; 243 243 # add extra maintainer(s) to every package 244 244 maintainers = (meta.maintainers or []) ++ [ ];
+21 -6
pkgs/development/interpreters/lua-5/interpreter.nix
··· 1 1 { lib, stdenv, fetchurl, readline 2 2 , compat ? false 3 3 , callPackage 4 - , packageOverrides ? (self: super: {}) 4 + , makeWrapper 5 + , packageOverrides ? (final: prev: {}) 5 6 , sourceVersion 6 7 , hash 7 8 , patches ? [] ··· 10 11 , staticOnly ? stdenv.hostPlatform.isStatic 11 12 }: 12 13 let 13 - luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;}; 14 + luaPackages = callPackage ../../lua-modules { 15 + lua = self; 16 + overrides = packageOverrides; 17 + }; 14 18 15 19 plat = if stdenv.isLinux then "linux" 16 20 else if stdenv.isDarwin then "macosx" ··· 31 35 sha256 = hash; 32 36 }; 33 37 34 - LuaPathSearchPaths = luaPackages.getLuaPathList luaversion; 35 - LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion; 38 + LuaPathSearchPaths = luaPackages.lib.luaPathList; 39 + LuaCPathSearchPaths = luaPackages.lib.luaCPathList; 36 40 setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths; 37 41 42 + nativeBuildInputs = [ makeWrapper ]; 38 43 buildInputs = [ readline ]; 39 44 40 45 inherit patches; 41 46 42 - postPatch = lib.optionalString (!stdenv.isDarwin && !staticOnly) '' 47 + # we can't pass flags to the lua makefile because for portability, everything is hardcoded 48 + postPatch = '' 49 + { 50 + echo -e ' 51 + #undef LUA_PATH_DEFAULT 52 + #define LUA_PATH_DEFAULT "./share/lua/${luaversion}/?.lua;./?.lua;./?/init.lua" 53 + #undef LUA_CPATH_DEFAULT 54 + #define LUA_CPATH_DEFAULT "./lib/lua/${luaversion}/?.so;./?.so;./lib/lua/${luaversion}/loadall.so" 55 + ' 56 + } >> src/luaconf.h 57 + '' + lib.optionalString (!stdenv.isDarwin && !staticOnly) '' 43 58 # Add a target for a shared library to the Makefile. 44 59 sed -e '1s/^/LUA_SO = liblua.so/' \ 45 60 -e 's/ALL_T *= */&$(LUA_SO) /' \ 46 61 -i src/Makefile 47 62 cat ${./lua-dso.make} >> src/Makefile 48 - ''; 63 + '' ; 49 64 50 65 # see configurePhase for additional flags (with space) 51 66 makeFlags = [
+5 -8
pkgs/development/interpreters/lua-5/wrap-lua.nix
··· 4 4 , makeWrapper 5 5 }: 6 6 7 - with lib; 8 - 9 7 # defined in trivial-builders.nix 10 8 # imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput 11 9 makeSetupHook { 12 - deps = makeWrapper; 13 - substitutions.executable = lua.interpreter; 14 - substitutions.lua = lua; 15 - substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; 16 - substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; 17 - 10 + deps = makeWrapper; 11 + substitutions.executable = lua.interpreter; 12 + substitutions.lua = lua; 13 + substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; 14 + substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; 18 15 } ./wrap.sh 19 16
+13 -6
pkgs/development/interpreters/lua-5/wrapper.nix
··· 11 11 let 12 12 env = let 13 13 paths = requiredLuaModules (extraLibs ++ [ lua ] ); 14 - in (buildEnv { 14 + in buildEnv { 15 15 name = "${lua.name}-env"; 16 16 17 17 inherit paths; 18 18 inherit ignoreCollisions; 19 19 extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall; 20 + 21 + nativeBuildInputs = [ 22 + makeWrapper 23 + (lua.pkgs.lua-setup-hook lua.LuaPathSearchPaths lua.LuaCPathSearchPaths) 24 + ]; 20 25 21 26 # we create wrapper for the binaries in the different packages 22 27 postBuild = '' ··· 37 42 rm -f "$out/bin/$prg" 38 43 if [ -x "$prg" ]; then 39 44 nix_debug "Making wrapper $prg" 40 - makeWrapper "$path/bin/$prg" "$out/bin/$prg" --suffix LUA_PATH ';' "$LUA_PATH" --suffix LUA_CPATH ';' "$LUA_CPATH" ${lib.concatStringsSep " " makeWrapperArgs} 45 + makeWrapper "$path/bin/$prg" "$out/bin/$prg" \ 46 + --set-default LUA_PATH ";;" \ 47 + --suffix LUA_PATH ';' "$LUA_PATH" \ 48 + --set-default LUA_CPATH ";;" \ 49 + --suffix LUA_CPATH ';' "$LUA_CPATH" \ 50 + ${lib.concatStringsSep " " makeWrapperArgs} 41 51 fi 42 52 fi 43 53 done ··· 62 72 ''; 63 73 }; 64 74 }; 65 - }).overrideAttrs (_: { 66 - # Add extra deps needed for postBuild hook. 67 - nativeBuildInputs = [ makeWrapper lua ]; 68 - }); 75 + }; 69 76 in env
+14 -10
pkgs/development/interpreters/luajit/default.nix
··· 10 10 , extraMeta ? { } 11 11 , callPackage 12 12 , self 13 - , packageOverrides ? (self: super: { }) 13 + , packageOverrides ? (final: prev: {}) 14 14 , enableFFI ? true 15 15 , enableJIT ? true 16 16 , enableJITDebugModule ? enableJIT ··· 62 62 # passed by nixpkgs CC wrapper is insufficient on its own 63 63 substituteInPlace src/Makefile --replace "#CCDEBUG= -g" "CCDEBUG= -g" 64 64 fi 65 + 66 + { 67 + echo -e ' 68 + #undef LUA_PATH_DEFAULT 69 + #define LUA_PATH_DEFAULT "./share/lua/${luaversion}/?.lua;./?.lua;./?/init.lua" 70 + #undef LUA_CPATH_DEFAULT 71 + #define LUA_CPATH_DEFAULT "./lib/lua/${luaversion}/?.so;./?.so;./lib/lua/${luaversion}/loadall.so" 72 + ' 73 + } >> src/luaconf.h 65 74 ''; 66 75 67 76 configurePhase = false; ··· 88 97 ln -s "$out"/bin/luajit-* "$out"/bin/luajit 89 98 ''; 90 99 91 - LuaPathSearchPaths = [ 92 - "lib/lua/${luaversion}/?.lua" 93 - "share/lua/${luaversion}/?.lua" 94 - "share/lua/${luaversion}/?/init.lua" 95 - "lib/lua/${luaversion}/?/init.lua" 96 - "share/${name}/?.lua" 97 - ]; 98 - LuaCPathSearchPaths = [ "lib/lua/${luaversion}/?.so" "share/lua/${luaversion}/?.so" ]; 99 - setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths; 100 + LuaPathSearchPaths = luaPackages.lib.luaPathList; 101 + LuaCPathSearchPaths = luaPackages.lib.luaCPathList; 102 + 103 + setupHook = luaPackages.lua-setup-hook luaPackages.lib.luaPathList luaPackages.lib.luaCPathList; 100 104 101 105 passthru = rec { 102 106 buildEnv = callPackage ../lua-5/wrapper.nix {
+3 -4
pkgs/development/lua-modules/default.nix
··· 1 1 # inspired by pkgs/development/haskell-modules/default.nix 2 2 { pkgs, lib 3 3 , lua 4 - , overrides ? (self: super: {}) 4 + , overrides ? (final: prev: {}) 5 5 }: 6 6 7 7 let ··· 15 15 overridenPackages = import ./overrides.nix { inherit pkgs; }; 16 16 17 17 generatedPackages = if (builtins.pathExists ./generated-packages.nix) then 18 - pkgs.callPackage ./generated-packages.nix { } else (self: super: {}); 18 + pkgs.callPackage ./generated-packages.nix { } else (final: prev: {}); 19 19 20 20 extensible-self = lib.makeExtensible 21 21 (extends overrides ··· 24 24 initialPackages 25 25 ) 26 26 ) 27 - ) 28 - ; 27 + ); 29 28 in 30 29 extensible-self
+63
pkgs/development/lua-modules/lib.nix
··· 1 + { pkgs, lib, lua }: 2 + let 3 + requiredLuaModules = drvs: with lib; let 4 + modules = filter hasLuaModule drvs; 5 + in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules)); 6 + # Check whether a derivation provides a lua module. 7 + hasLuaModule = drv: drv ? luaModule; 8 + in 9 + rec { 10 + inherit hasLuaModule requiredLuaModules; 11 + 12 + luaPathList = [ 13 + "share/lua/${lua.luaversion}/?.lua" 14 + "share/lua/${lua.luaversion}/?/init.lua" 15 + ]; 16 + luaCPathList = [ 17 + "lib/lua/${lua.luaversion}/?.so" 18 + ]; 19 + 20 + /* generate paths without a prefix 21 + */ 22 + luaPathRelStr = lib.concatStringsSep ";" luaPathList; 23 + luaCPathRelStr = lib.concatStringsSep ";" luaCPathList; 24 + 25 + /* generate LUA_(C)PATH value for a specific derivation, i.e., with absolute paths 26 + */ 27 + genLuaPathAbsStr = drv: lib.concatMapStringsSep ";" (x: "${drv}/${x}") luaPathList; 28 + genLuaCPathAbsStr = drv: lib.concatMapStringsSep ";" (x: "${drv}/${x}") luaCPathList; 29 + 30 + /* Generate a LUA_PATH with absolute paths 31 + */ 32 + # genLuaPathAbs = drv: 33 + # lib.concatStringsSep ";" (map (x: "${drv}/x") luaPathList); 34 + 35 + luaAtLeast = lib.versionAtLeast lua.luaversion; 36 + luaOlder = lib.versionOlder lua.luaversion; 37 + isLua51 = (lib.versions.majorMinor lua.version) == "5.1"; 38 + isLua52 = (lib.versions.majorMinor lua.version) == "5.2"; 39 + isLua53 = lua.luaversion == "5.3"; 40 + isLuaJIT = lib.getName lua == "luajit"; 41 + 42 + /* generates the relative path towards the folder where 43 + seems stable even when using lua_modules_path = "" 44 + 45 + Example: 46 + getDataFolder luaPackages.stdlib 47 + => stdlib-41.2.2-1-rocks/stdlib/41.2.2-1/doc 48 + */ 49 + getDataFolder = drv: 50 + "${drv.pname}-${drv.version}-rocks/${drv.pname}/${drv.version}"; 51 + 52 + /* Convert derivation to a lua module. 53 + so that luaRequireModules can be run later 54 + */ 55 + toLuaModule = drv: 56 + drv.overrideAttrs( oldAttrs: { 57 + # Use passthru in order to prevent rebuilds when possible. 58 + passthru = (oldAttrs.passthru or {}) // { 59 + luaModule = lua; 60 + requiredLuaModules = requiredLuaModules drv.propagatedBuildInputs; 61 + }; 62 + }); 63 + }
+6
pkgs/development/lua-modules/overrides.nix
··· 363 363 ''; 364 364 }); 365 365 366 + # TODO just while testing, remove afterwards 367 + # toVimPlugin should do it instead 368 + gitsigns-nvim = super.gitsigns-nvim.overrideAttrs(oa: { 369 + nativeBuildInputs = oa.nativeBuildInputs or [] ++ [ pkgs.vimUtils.vimGenDocHook ]; 370 + }); 371 + 366 372 # aliases 367 373 cjson = super.lua-cjson; 368 374 }
+3 -3
pkgs/games/mudlet/default.nix
··· 2 2 , boost, libGLU, lua, cmake, which, pkg-config, }: 3 3 4 4 let 5 - luaEnv = lua.withPackages(ps: with ps; [ luazip luafilesystem lrexlib-pcre luasql-sqlite3 lua-yajl luautf8 ]); 5 + luaEnv = lua.withPackages(ps: with ps; [ 6 + luazip luafilesystem lrexlib-pcre luasql-sqlite3 lua-yajl luautf8 7 + ]); 6 8 in 7 9 stdenv.mkDerivation rec { 8 10 pname = "mudlet"; ··· 39 41 cp -r ../mudlet.png $out/share/pixmaps/ 40 42 41 43 makeQtWrapper $out/mudlet $out/bin/mudlet \ 42 - --set LUA_CPATH "${luaEnv}/lib/lua/${lua.luaversion}/?.so" \ 43 - --prefix LUA_PATH : "$NIX_LUA_PATH" \ 44 44 --prefix LD_LIBRARY_PATH : "${libsForQt5.qtkeychain}/lib/" \ 45 45 --run "cd $out"; 46 46 '';
+16 -15
pkgs/servers/xmpp/prosody/default.nix
··· 1 1 { stdenv, fetchurl, lib, libidn, openssl, makeWrapper, fetchhg 2 - , lua5, luasocket, luasec, luaexpat, luafilesystem, luabitop 2 + , lua 3 3 , nixosTests 4 - , withLibevent ? true, luaevent ? null 5 - , withDBI ? true, luadbi ? null 4 + , withLibevent ? true 5 + , withDBI ? true 6 6 # use withExtraLibs to add additional dependencies of community modules 7 7 , withExtraLibs ? [ ] 8 8 , withOnlyInstalledCommunityModules ? [ ] 9 9 , withCommunityModules ? [ ] }: 10 10 11 - assert withLibevent -> luaevent != null; 12 - assert withDBI -> luadbi != null; 13 - 14 11 with lib; 15 12 16 13 14 + let 15 + luaEnv = lua.withPackages(p: with p; [ 16 + luasocket luasec luaexpat luafilesystem luabitop luadbi-sqlite3 17 + ] 18 + ++ lib.optional withLibevent p.luaevent 19 + ++ lib.optional withDBI p.luadbi 20 + ); 21 + in 17 22 stdenv.mkDerivation rec { 18 23 version = "0.11.10"; # also update communityModules 19 24 pname = "prosody"; ··· 41 46 sha256 = "02gj1b8sdmdvymsdmjpq47zrl7sg578jcdxbbq18s44f3njmc9q1"; 42 47 }; 43 48 49 + nativeBuildInputs = [ makeWrapper ]; 44 50 buildInputs = [ 45 - lua5 makeWrapper libidn openssl 46 - ] 47 - # Lua libraries 48 - ++ [ 49 - luasocket luasec luaexpat luafilesystem luabitop 51 + luaEnv libidn openssl 50 52 ] 51 - ++ optional withLibevent luaevent 52 - ++ optional withDBI luadbi 53 53 ++ withExtraLibs; 54 54 55 55 56 56 configureFlags = [ 57 57 "--ostype=linux" 58 - "--with-lua-include=${lua5}/include" 59 - "--with-lua=${lua5}" 58 + "--with-lua-include=${luaEnv}/include" 59 + "--with-lua=${luaEnv}" 60 60 ]; 61 61 62 62 postBuild = '' 63 63 make -C tools/migration 64 64 ''; 65 65 66 + # the wrapping should go away once lua hook is fixed 66 67 postInstall = '' 67 68 ${concatMapStringsSep "\n" (module: '' 68 69 cp -r $communityModules/mod_${module} $out/lib/prosody/modules/
+3 -6
pkgs/top-level/all-packages.nix
··· 19950 19950 19951 19951 prosody = callPackage ../servers/xmpp/prosody { 19952 19952 # _compat can probably be removed on next minor version after 0.10.0 19953 - lua5 = lua5_2_compat; 19954 - withExtraLibs = [ luaPackages.luadbi-sqlite3 ]; 19955 - inherit (lua52Packages) luasocket luasec luaexpat luafilesystem luabitop luaevent luadbi; 19953 + lua = lua5_2_compat; 19954 + withExtraLibs = []; 19956 19955 }; 19957 19956 19958 19957 biboumi = callPackage ../servers/xmpp/biboumi { }; ··· 28277 28276 28278 28277 neovim-remote = callPackage ../applications/editors/neovim/neovim-remote.nix { }; 28279 28278 28280 - vis = callPackage ../applications/editors/vis { 28281 - inherit (lua52Packages) lpeg; 28282 - }; 28279 + vis = callPackage ../applications/editors/vis { }; 28283 28280 28284 28281 viw = callPackage ../applications/editors/viw { }; 28285 28282
+32 -57
pkgs/top-level/lua-packages.nix
··· 18 18 packages = ( self: 19 19 20 20 let 21 - luaAtLeast = lib.versionAtLeast lua.luaversion; 22 - luaOlder = lib.versionOlder lua.luaversion; 23 - isLua51 = (lib.versions.majorMinor lua.version) == "5.1"; 24 - isLua52 = (lib.versions.majorMinor lua.version) == "5.2"; 25 - isLua53 = lua.luaversion == "5.3"; 26 - isLuaJIT = lib.getName lua == "luajit"; 27 21 28 - lua-setup-hook = callPackage ../development/interpreters/lua-5/setup-hook.nix { }; 29 - 30 - # Check whether a derivation provides a lua module. 31 - hasLuaModule = drv: drv ? luaModule ; 22 + # a function of lua_path / lua_cpath 23 + lua-setup-hook = callPackage ../development/interpreters/lua-5/setup-hook.nix { 24 + inherit lib; 25 + }; 32 26 33 27 callPackage = pkgs.newScope self; 34 28 35 - requiredLuaModules = drvs: with lib; let 36 - modules = filter hasLuaModule drvs; 37 - in unique ([lua] ++ modules ++ concatLists (catAttrs "requiredLuaModules" modules)); 38 - 39 - # Convert derivation to a lua module. 40 - toLuaModule = drv: 41 - drv.overrideAttrs( oldAttrs: { 42 - # Use passthru in order to prevent rebuilds when possible. 43 - passthru = (oldAttrs.passthru or {})// { 44 - luaModule = lua; 45 - requiredLuaModules = requiredLuaModules drv.propagatedBuildInputs; 46 - }; 47 - }); 48 - 49 - 50 - platformString = 51 - if stdenv.isDarwin then "macosx" 52 - else if stdenv.isFreeBSD then "freebsd" 53 - else if stdenv.isLinux then "linux" 54 - else if stdenv.isSunOS then "solaris" 55 - else throw "unsupported platform"; 56 - 57 29 buildLuaApplication = args: buildLuarocksPackage ({namePrefix="";} // args ); 58 30 59 - buildLuarocksPackage = with pkgs.lib; makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix { 60 - inherit toLuaModule; 31 + buildLuarocksPackage = lib.makeOverridable(callPackage ../development/interpreters/lua-5/build-lua-package.nix { 61 32 inherit lua; 33 + inherit (pkgs) lib; 34 + inherit (luaLib) toLuaModule; 62 35 }); 63 - in 64 - with self; { 65 36 66 - getLuaPathList = majorVersion: [ 67 - "share/lua/${majorVersion}/?.lua" 68 - "share/lua/${majorVersion}/?/init.lua" 69 - ]; 70 - getLuaCPathList = majorVersion: [ 71 - "lib/lua/${majorVersion}/?.so" 72 - ]; 73 - 74 - # helper functions for dealing with LUA_PATH and LUA_CPATH 75 - getPath = drv: pathListForVersion: 76 - lib.concatMapStringsSep ";" (path: "${drv}/${path}") (pathListForVersion lua.luaversion); 77 - getLuaPath = drv: getPath drv getLuaPathList; 78 - getLuaCPath = drv: getPath drv getLuaCPathList; 37 + luaLib = import ../development/lua-modules/lib.nix { 38 + inherit (pkgs) lib; 39 + inherit pkgs lua; 40 + }; 79 41 80 42 #define build lua package function 81 43 buildLuaPackage = callPackage ../development/lua-modules/generic { 82 - inherit lua writeText; 44 + inherit writeText; 83 45 }; 84 46 47 + getPath = drv: pathListForVersion: 48 + lib.concatMapStringsSep ";" (path: "${drv}/${path}") pathListForVersion; 85 49 86 - inherit toLuaModule hasLuaModule lua-setup-hook; 87 - inherit buildLuarocksPackage buildLuaApplication; 88 - inherit requiredLuaModules luaOlder luaAtLeast 89 - isLua51 isLua52 isLua53 isLuaJIT lua callPackage; 50 + in 51 + { 52 + # helper functions for dealing with LUA_PATH and LUA_CPATH 53 + lib = luaLib; 54 + 55 + getLuaPath = drv: luaLib.getPath drv (luaLib.luaPathList lua.luaversion) ; 56 + getLuaCPath = drv: luaLib.getPath drv (luaLib.luaCPathList lua.luaversion) ; 57 + 58 + 59 + inherit lua lua-setup-hook callPackage; 60 + inherit buildLuaPackage buildLuarocksPackage buildLuaApplication; 61 + inherit (luaLib) luaOlder luaAtLeast isLua51 isLua52 isLua53 isLuaJIT 62 + requiredLuaModules toLuaModule hasLuaModule; 90 63 91 64 # wraps programs in $out/bin with valid LUA_PATH/LUA_CPATH 92 65 wrapLua = callPackage ../development/interpreters/lua-5/wrap-lua.nix { 93 - inherit lua; inherit (pkgs) makeSetupHook makeWrapper; 66 + inherit lua lib; 67 + inherit (pkgs) makeSetupHook makeWrapper; 94 68 }; 95 69 96 70 luarocks = callPackage ../development/tools/misc/luarocks { 97 - inherit lua; 71 + inherit lua lib; 98 72 }; 99 73 74 + # a fork of luarocks used to generate nix lua derivations from rockspecs 100 75 luarocks-nix = callPackage ../development/tools/misc/luarocks/luarocks-nix.nix { }; 101 76 102 77 luxio = buildLuaPackage { ··· 132 107 }; 133 108 }; 134 109 135 - vicious = toLuaModule(stdenv.mkDerivation rec { 110 + vicious = luaLib.toLuaModule( stdenv.mkDerivation rec { 136 111 pname = "vicious"; 137 112 version = "2.5.0"; 138 113