diff options
author | github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> | 2022-06-19 00:02:36 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-19 00:02:36 +0000 |
commit | b7aba4fb0f6e828ff725e027490406f437e4ddee (patch) | |
tree | 6973ff677fe6bc06bb5de0ad7c320b7d316032ba /pkgs/development/interpreters/lua-5 | |
parent | 5ee636b083ffb63540cfac8b5fa594951fd1f319 (diff) | |
parent | 861771aac25619fb24c57d846f77cf820f421658 (diff) |
Merge master into staging-next
Diffstat (limited to 'pkgs/development/interpreters/lua-5')
3 files changed, 42 insertions, 5 deletions
diff --git a/pkgs/development/interpreters/lua-5/build-lua-package.nix b/pkgs/development/interpreters/lua-5/build-lua-package.nix index ff93e842eeae1..0af7b470b0b38 100644 --- a/pkgs/development/interpreters/lua-5/build-lua-package.nix +++ b/pkgs/development/interpreters/lua-5/build-lua-package.nix @@ -4,6 +4,7 @@ , wrapLua # Whether the derivation provides a lua module or not. , toLuaModule +, luarocksCheckHook }: { @@ -42,6 +43,7 @@ pname , passthru ? {} , doCheck ? false +, doInstallCheck ? false # Non-Lua / system (e.g. C library) dependencies. Is a list of deps, where # each dep is either a derivation, or an attribute set like @@ -97,10 +99,12 @@ let # Filter out the lua derivation itself from the Lua module dependency # closure, as it doesn't have a rock tree :) requiredLuaRocks = lib.filter (d: d ? luaModule) - (lua.pkgs.requiredLuaModules luarocksDrv.propagatedBuildInputs); + (lua.pkgs.requiredLuaModules (luarocksDrv.nativeBuildInputs ++ luarocksDrv.propagatedBuildInputs)); # example externalDeps': [ { name = "CRYPTO"; dep = pkgs.openssl; } ] - externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) (luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs)); + externalDepsGenerated = lib.unique (lib.filter (drv: !drv ? luaModule) ( + luarocksDrv.nativeBuildInputs ++ luarocksDrv.propagatedBuildInputs ++ luarocksDrv.buildInputs) + ); externalDeps' = lib.filter (dep: !lib.isDerivation dep) externalDeps; luarocksDrv = toLuaModule ( lua.stdenv.mkDerivation ( @@ -108,15 +112,17 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab name = namePrefix + pname + "-" + version; - buildInputs = [ wrapLua lua.pkgs.luarocks ] + nativeBuildInputs = [ + wrapLua + lua.pkgs.luarocks + ] ++ buildInputs - ++ lib.optionals doCheck checkInputs + ++ lib.optionals doCheck ([ luarocksCheckHook ] ++ checkInputs) ++ (map (d: d.dep) externalDeps') ; # propagate lua to active setup-hook in nix-shell propagatedBuildInputs = propagatedBuildInputs ++ [ lua ]; - inherit doCheck; # @-patterns do not capture formal argument default values, so we need to # explicitly inherit this for it to be available as a shell variable in the @@ -190,6 +196,14 @@ builtins.removeAttrs attrs ["disabled" "checkInputs" "externalDeps" "extraVariab runHook postCheck ''; + LUAROCKS_CONFIG="$PWD/${luarocks_config}"; + + shellHook = '' + runHook preShell + export LUAROCKS_CONFIG="$PWD/${luarocks_config}"; + runHook postShell + ''; + passthru = { inherit lua; # The lua interpreter inherit externalDeps; diff --git a/pkgs/development/interpreters/lua-5/hooks/default.nix b/pkgs/development/interpreters/lua-5/hooks/default.nix index 8fd725a9b8a4f..61261ca3d046e 100644 --- a/pkgs/development/interpreters/lua-5/hooks/default.nix +++ b/pkgs/development/interpreters/lua-5/hooks/default.nix @@ -24,4 +24,9 @@ in { mv hook.sh $out ''; + luarocksCheckHook = callPackage ({ luarocks }: + makeSetupHook { + name = "luarocks-check-hook"; + deps = [ luarocks ]; + } ./luarocks-check-hook.sh) {}; } diff --git a/pkgs/development/interpreters/lua-5/hooks/luarocks-check-hook.sh b/pkgs/development/interpreters/lua-5/hooks/luarocks-check-hook.sh new file mode 100644 index 0000000000000..bc6c6255d5601 --- /dev/null +++ b/pkgs/development/interpreters/lua-5/hooks/luarocks-check-hook.sh @@ -0,0 +1,18 @@ +# Setup hook for checking whether Python imports succeed +echo "Sourcing luarocks-check-hook.sh" + +luarocksCheckPhase () { + echo "Executing luarocksCheckPhase" + runHook preCheck + + luarocks test + + runHook postCheck + echo "Finished executing luarocksCheckPhase" +} + +if [ -z "${dontLuarocksCheck-}" ] && [ -z "${checkPhase-}" ]; then + echo "Using luarocksCheckPhase" + checkPhase+=" luarocksCheckPhase" +fi + |