about summary refs log tree commit diff
path: root/pkgs/development/lua-modules/generic
diff options
context:
space:
mode:
authorAlexei Robyn <shados@shados.net>2019-08-21 23:03:11 +1000
committerFrederik Rietdijk <freddyrietdijk@fridh.nl>2019-09-01 17:42:20 +0200
commitc62337d9c7ff70e9bdfe317388c4fa5d6202142a (patch)
tree4d1a9169d2b04723184e18f3b68d9e8e9c319310 /pkgs/development/lua-modules/generic
parent59d85b9910e8b76be9b2970bb268c6689bebc205 (diff)
lua*Packages: Consolidate separate setup hooks together
- Lua packages now consistently use LUA_PATH/LUA_CPATH rather than a mix
  of those and NIX_LUA_PATH/NIX_LUA_CPATH
- Lua libraries are now consistently only added to the search path
variables if:
    1) The library actually has a corresponding directory to search
    2) The library is not already present in the search path
  This should help prevent the search paths from growing overly large
- Fixed bugs in some path helpers
- Changed the affected shell script indentation to 2 spaces; nixpkgs
  shell scripts are inconsistently split between 2 and 4 space
  indentation, but 2 matches better with the Nix expressions, so IMO it
  makes more sense
Diffstat (limited to 'pkgs/development/lua-modules/generic')
-rw-r--r--pkgs/development/lua-modules/generic/default.nix37
1 files changed, 4 insertions, 33 deletions
diff --git a/pkgs/development/lua-modules/generic/default.nix b/pkgs/development/lua-modules/generic/default.nix
index 3dae32b5e15d7..71e1f7c05e6e6 100644
--- a/pkgs/development/lua-modules/generic/default.nix
+++ b/pkgs/development/lua-modules/generic/default.nix
@@ -1,6 +1,6 @@
 { lua, writeText, toLuaModule }:
 
-{ buildInputs ? [], disabled ? false, ... } @ attrs:
+{ disabled ? false, ... } @ attrs:
 
 if disabled then
   throw "${attrs.name} not supported by interpreter lua-${lua.luaversion}"
@@ -18,37 +18,8 @@ else
     //
     {
       name = "lua${lua.luaversion}-" + attrs.name;
-      buildInputs = buildInputs ++ [ lua ];
-
-      setupHook = writeText "setup-hook.sh" ''
-        # check for lua/clua modules and don't add duplicates
-
-        addLuaLibPath() {
-          local package_path="$1/share/lua/${lua.luaversion}"
-          if [[ ! -d $package_path ]]; then return; fi
-          if [[ $LUA_PATH = *"$package_path"* ]]; then return; fi
-
-          if [[ -z $LUA_PATH ]]; then
-            export LUA_PATH="$package_path/?.lua;$package_path/?/init.lua"
-          else
-            export LUA_PATH="$LUA_PATH;$package_path/?.lua;$package_path/?/init.lua"
-          fi
-        }
-
-        addLuaLibCPath() {
-          local package_cpath="$1/lib/lua/${lua.luaversion}"
-          if [[ ! -d $package_cpath ]]; then return; fi
-          if [[ $LUA_CPATH = *"$package_cpath"* ]]; then return; fi
-
-          if [[ -z $LUA_CPATH ]]; then
-            export LUA_CPATH="$package_cpath/?.so"
-          else
-            export LUA_CPATH="$LUA_CPATH;$package_cpath/?.so"
-          fi
-        }
-
-        addEnvHooks "$hostOffset" addLuaLibPath
-        addEnvHooks "$hostOffset" addLuaLibCPath
-      '';
+      propagatedBuildInputs = [
+        lua # propagate it for its setup-hook
+      ];
     }
   ) )