summaryrefslogtreecommitdiffstats
path: root/pkgs/development/interpreters
diff options
context:
space:
mode:
authorMatthieu Coudron <mcoudron@hotmail.com>2021-09-12 00:01:49 +0200
committerMatthieu Coudron <mcoudron@hotmail.com>2021-09-12 03:03:56 +0200
commit88842910b52c146bc5ef9c78eed34e5e570ef76c (patch)
tree209d81c2060e5ae5f211b9a473e42fab9be57888 /pkgs/development/interpreters
parent0b6d33c2ed177be6d937e3043ac77252007a77b1 (diff)
lua: introduced a lua lib
Goal is to improve separation between packages and utilities. Can help with autocompletion/navigate nixpkgs faster. Also it will help standardize how LUA_PATH is exported across packages, so that one can more easily make lua changes across nixpkgs (for instance changing where lua modules are installed).
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r--pkgs/development/interpreters/lua-5/build-lua-package.nix2
-rw-r--r--pkgs/development/interpreters/lua-5/interpreter.nix26
-rw-r--r--pkgs/development/interpreters/lua-5/wrap-lua.nix13
-rw-r--r--pkgs/development/interpreters/lua-5/wrapper.nix19
-rw-r--r--pkgs/development/interpreters/luajit/default.nix24
5 files changed, 53 insertions, 31 deletions
diff --git a/pkgs/development/interpreters/lua-5/build-lua-package.nix b/pkgs/development/interpreters/lua-5/build-lua-package.nix
index 5639b2a4bb90..64e872ad5f63 100644
--- a/pkgs/development/interpreters/lua-5/build-lua-package.nix
+++ b/pkgs/development/interpreters/lua-5/build-lua-package.nix
@@ -238,7 +238,7 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab
inherit externalDeps;
} // passthru;
- meta = with lib.maintainers; {
+ meta = {
platforms = lua.meta.platforms;
# add extra maintainer(s) to every package
maintainers = (meta.maintainers or []) ++ [ ];
diff --git a/pkgs/development/interpreters/lua-5/interpreter.nix b/pkgs/development/interpreters/lua-5/interpreter.nix
index 3476b2b648b6..c6b4f478f633 100644
--- a/pkgs/development/interpreters/lua-5/interpreter.nix
+++ b/pkgs/development/interpreters/lua-5/interpreter.nix
@@ -1,7 +1,8 @@
{ lib, stdenv, fetchurl, readline
, compat ? false
, callPackage
-, packageOverrides ? (self: super: {})
+, makeWrapper
+, packageOverrides ? (final: prev: {})
, sourceVersion
, hash
, patches ? []
@@ -10,7 +11,9 @@
, staticOnly ? stdenv.hostPlatform.isStatic
}:
let
-luaPackages = callPackage ../../lua-modules {lua=self; overrides=packageOverrides;};
+ luaPackages = callPackage ../../lua-modules {
+ lua=self; overrides=packageOverrides;
+ };
plat = if stdenv.isLinux then "linux"
else if stdenv.isDarwin then "macosx"
@@ -31,21 +34,32 @@ self = stdenv.mkDerivation rec {
sha256 = hash;
};
- LuaPathSearchPaths = luaPackages.getLuaPathList luaversion;
- LuaCPathSearchPaths = luaPackages.getLuaCPathList luaversion;
+ LuaPathSearchPaths = luaPackages.lib.luaPathList;
+ LuaCPathSearchPaths = luaPackages.lib.luaCPathList;
setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
+ nativeBuildInputs = [ makeWrapper ];
buildInputs = [ readline ];
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.
sed -e '1s/^/LUA_SO = liblua.so/' \
-e 's/ALL_T *= */&$(LUA_SO) /' \
-i src/Makefile
cat ${./lua-dso.make} >> src/Makefile
- '';
+ '' ;
# see configurePhase for additional flags (with space)
makeFlags = [
diff --git a/pkgs/development/interpreters/lua-5/wrap-lua.nix b/pkgs/development/interpreters/lua-5/wrap-lua.nix
index f00e0d5ac336..049afcd6116d 100644
--- a/pkgs/development/interpreters/lua-5/wrap-lua.nix
+++ b/pkgs/development/interpreters/lua-5/wrap-lua.nix
@@ -4,16 +4,13 @@
, makeWrapper
}:
-with lib;
-
# defined in trivial-builders.nix
# imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput
makeSetupHook {
- deps = makeWrapper;
- substitutions.executable = lua.interpreter;
- substitutions.lua = lua;
- substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
- substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
-
+ deps = makeWrapper;
+ substitutions.executable = lua.interpreter;
+ substitutions.lua = lua;
+ substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
+ substitutions.LuaCPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths;
} ./wrap.sh
diff --git a/pkgs/development/interpreters/lua-5/wrapper.nix b/pkgs/development/interpreters/lua-5/wrapper.nix
index 0459b67534d4..b9ac255d2432 100644
--- a/pkgs/development/interpreters/lua-5/wrapper.nix
+++ b/pkgs/development/interpreters/lua-5/wrapper.nix
@@ -11,13 +11,18 @@
let
env = let
paths = requiredLuaModules (extraLibs ++ [ lua ] );
- in (buildEnv {
+ in buildEnv {
name = "${lua.name}-env";
inherit paths;
inherit ignoreCollisions;
extraOutputsToInstall = [ "out" ] ++ extraOutputsToInstall;
+ nativeBuildInputs = [
+ makeWrapper
+ (lua.pkgs.lua-setup-hook lua.LuaPathSearchPaths lua.LuaCPathSearchPaths)
+ ];
+
# we create wrapper for the binaries in the different packages
postBuild = ''
if [ -L "$out/bin" ]; then
@@ -37,7 +42,12 @@ let
rm -f "$out/bin/$prg"
if [ -x "$prg" ]; then
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
done
@@ -62,8 +72,5 @@ let
'';
};
};
- }).overrideAttrs (_: {
- # Add extra deps needed for postBuild hook.
- nativeBuildInputs = [ makeWrapper lua ];
- });
+ };
in env
diff --git a/pkgs/development/interpreters/luajit/default.nix b/pkgs/development/interpreters/luajit/default.nix
index 6a163c4b562f..ac74610bcce9 100644
--- a/pkgs/development/interpreters/luajit/default.nix
+++ b/pkgs/development/interpreters/luajit/default.nix
@@ -10,7 +10,7 @@
, extraMeta ? { }
, callPackage
, self
-, packageOverrides ? (self: super: { })
+, packageOverrides ? (final: prev: {})
, enableFFI ? true
, enableJIT ? true
, enableJITDebugModule ? enableJIT
@@ -62,6 +62,15 @@ stdenv.mkDerivation rec {
# passed by nixpkgs CC wrapper is insufficient on its own
substituteInPlace src/Makefile --replace "#CCDEBUG= -g" "CCDEBUG= -g"
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;
@@ -88,15 +97,10 @@ stdenv.mkDerivation rec {
ln -s "$out"/bin/luajit-* "$out"/bin/luajit
'';
- LuaPathSearchPaths = [
- "lib/lua/${luaversion}/?.lua"
- "share/lua/${luaversion}/?.lua"
- "share/lua/${luaversion}/?/init.lua"
- "lib/lua/${luaversion}/?/init.lua"
- "share/${name}/?.lua"
- ];
- LuaCPathSearchPaths = [ "lib/lua/${luaversion}/?.so" "share/lua/${luaversion}/?.so" ];
- setupHook = luaPackages.lua-setup-hook LuaPathSearchPaths LuaCPathSearchPaths;
+ LuaPathSearchPaths = luaPackages.lib.luaPathList;
+ LuaCPathSearchPaths = luaPackages.lib.luaCPathList;
+
+ setupHook = luaPackages.lua-setup-hook luaPackages.lib.luaPathList luaPackages.lib.luaCPathList;
passthru = rec {
buildEnv = callPackage ../lua-5/wrapper.nix {