about summary refs log tree commit diff
path: root/pkgs/development/interpreters/lua-5/hooks
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/interpreters/lua-5/hooks')
-rw-r--r--pkgs/development/interpreters/lua-5/hooks/default.nix14
-rw-r--r--pkgs/development/interpreters/lua-5/hooks/setup-hook.sh54
2 files changed, 1 insertions, 67 deletions
diff --git a/pkgs/development/interpreters/lua-5/hooks/default.nix b/pkgs/development/interpreters/lua-5/hooks/default.nix
index ca9c15e8a3b1e..5f935626fec45 100644
--- a/pkgs/development/interpreters/lua-5/hooks/default.nix
+++ b/pkgs/development/interpreters/lua-5/hooks/default.nix
@@ -2,7 +2,6 @@
 { lua
 , lib
 , makeSetupHook
-, findutils
 , runCommand
 }:
 
@@ -10,19 +9,6 @@ let
   callPackage = lua.pkgs.callPackage;
 in {
 
-  lua-setup-hook = LuaPathSearchPaths: LuaCPathSearchPaths:
-    let
-      hook = ./setup-hook.sh;
-    in runCommand "lua-setup-hook.sh" {
-      # hum doesn't seem to like caps !! BUG ?
-      luapathsearchpaths=lib.escapeShellArgs LuaPathSearchPaths;
-      luacpathsearchpaths=lib.escapeShellArgs LuaCPathSearchPaths;
-    } ''
-      cp ${hook} hook.sh
-      substituteAllInPlace hook.sh
-      mv hook.sh $out
-    '';
-
   luarocksCheckHook = callPackage ({ luarocks }:
     makeSetupHook {
       name = "luarocks-check-hook";
diff --git a/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh b/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
index 3027021661393..0e9aa689706e7 100644
--- a/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
+++ b/pkgs/development/interpreters/lua-5/hooks/setup-hook.sh
@@ -1,56 +1,4 @@
 # set -e
 
-nix_print() {
-  if [ ${NIX_DEBUG:-0} -ge $1 ]; then
-    echo "$2"
-  fi
-}
-
-nix_debug() {
-  nix_print 3 "$1"
-}
-
-addToLuaSearchPathWithCustomDelimiter() {
-  local varName="$1"
-  local absPattern="$2"
-
-  # export only if we haven't already got this dir in the search path
-  if [[ ${!varName-} == *"$absPattern"* ]]; then return; fi
-
-  # if the path variable has not yet been set, initialize it to ";;"
-  # this is a magic value that will be replaced by the default,
-  # allowing relative modules to be used even when there are system modules.
-  if [[ ! -v "${varName}" ]]; then export "${varName}=;;"; fi
-
-  # export only if the folder contains lua files
-  shopt -s globstar
-
-  local adjustedPattern="${absPattern/\?/\*\*\/\*}"
-  for _file in $adjustedPattern; do
-    export "${varName}=${!varName:+${!varName};}${absPattern}"
-    shopt -u globstar
-    return;
-  done
-  shopt -u globstar
-}
-
-addToLuaPath() {
-  local dir="$1"
-
-  if [[ ! -d "$dir" ]]; then
-    nix_debug "$dir not a directory abort"
-    return 0
-  fi
-  cd "$dir"
-  for pattern in @luapathsearchpaths@; do
-    addToLuaSearchPathWithCustomDelimiter LUA_PATH "$PWD/$pattern"
-  done
-
-  # LUA_CPATH
-  for pattern in @luacpathsearchpaths@; do
-    addToLuaSearchPathWithCustomDelimiter LUA_CPATH "$PWD/$pattern"
-  done
-  cd - >/dev/null
-}
-
+source ./utils.sh
 addEnvHooks "$hostOffset" addToLuaPath