2024-06-05 15:53:02 +00:00
|
|
|
/*
|
|
|
|
This is a minimal/manual luarocks derivation used by `buildLuarocksPackage` to install lua packages.
|
|
|
|
|
|
|
|
As a nix user, you should use the generated lua.pkgs.luarocks that contains a luarocks manifest
|
|
|
|
which makes it recognizable to luarocks.
|
|
|
|
Generating the manifest for luarocks_bootstrap seemed too hackish, which is why we end up
|
|
|
|
with two "luarocks" derivations.
|
|
|
|
|
|
|
|
*/
|
2022-10-30 15:09:59 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, curl
|
|
|
|
, makeWrapper
|
|
|
|
, which
|
|
|
|
, unzip
|
2020-04-24 23:36:52 +00:00
|
|
|
, lua
|
2022-10-30 15:09:59 +00:00
|
|
|
# for 'luarocks pack'
|
2020-04-24 23:36:52 +00:00
|
|
|
, zip
|
2022-06-16 17:23:12 +00:00
|
|
|
, nix-update-script
|
2022-10-30 15:09:59 +00:00
|
|
|
# some packages need to be compiled with cmake
|
2020-04-24 23:36:52 +00:00
|
|
|
, cmake
|
2021-09-18 10:52:07 +00:00
|
|
|
, installShellFiles
|
2020-04-24 23:36:52 +00:00
|
|
|
}:
|
|
|
|
|
2023-04-29 16:46:19 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2024-07-27 06:49:29 +00:00
|
|
|
pname = "luarocks_bootstrap";
|
|
|
|
version = "3.11.1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "luarocks";
|
|
|
|
repo = "luarocks";
|
2023-04-29 16:46:19 +00:00
|
|
|
rev = "v${finalAttrs.version}";
|
2024-07-27 06:49:29 +00:00
|
|
|
hash = "sha256-GglygI8HP+aDFEuucOkjQ2Pgfv4+jW+og+2vL3KoZCQ=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
patches = [
|
|
|
|
./darwin-3.7.0.patch
|
|
|
|
];
|
2021-04-26 19:14:03 +00:00
|
|
|
|
|
|
|
postPatch = lib.optionalString stdenv.targetPlatform.isDarwin ''
|
|
|
|
substituteInPlace src/luarocks/core/cfg.lua --subst-var-by 'darwinMinVersion' '${stdenv.targetPlatform.darwinMinVersion}'
|
|
|
|
'';
|
|
|
|
|
2022-07-14 12:49:19 +00:00
|
|
|
# Manually written ./configure does not support --build= or --host=:
|
|
|
|
# Error: Unknown flag: --build=x86_64-unknown-linux-gnu
|
|
|
|
configurePlatforms = [ ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
preConfigure = ''
|
|
|
|
lua -e "" || {
|
|
|
|
luajit -e "" && {
|
|
|
|
export LUA_SUFFIX=jit
|
|
|
|
configureFlags="$configureFlags --lua-suffix=$LUA_SUFFIX"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
lua_inc="$(echo "${lua}/include"/*/)"
|
|
|
|
if test -n "$lua_inc"; then
|
|
|
|
configureFlags="$configureFlags --with-lua-include=$lua_inc"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper installShellFiles lua unzip ];
|
2021-09-18 10:52:07 +00:00
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
buildInputs = [ curl which ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
postInstall = ''
|
|
|
|
sed -e "1s@.*@#! ${lua}/bin/lua$LUA_SUFFIX@" -i "$out"/bin/*
|
2022-09-30 11:47:45 +00:00
|
|
|
substituteInPlace $out/etc/luarocks/* \
|
2024-09-19 14:19:46 +00:00
|
|
|
--replace-quiet '${lua.luaOnBuild}' '${lua}'
|
2024-02-29 20:09:43 +00:00
|
|
|
''
|
|
|
|
+ lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
|
|
|
|
installShellCompletion --cmd luarocks \
|
|
|
|
--bash <($out/bin/luarocks completion bash) \
|
|
|
|
--fish <($out/bin/luarocks completion fish) \
|
|
|
|
--zsh <($out/bin/luarocks completion zsh)
|
2022-09-30 11:47:45 +00:00
|
|
|
|
2024-02-29 20:09:43 +00:00
|
|
|
installShellCompletion --cmd luarocks-admin \
|
|
|
|
--bash <($out/bin/luarocks-admin completion bash) \
|
|
|
|
--fish <($out/bin/luarocks-admin completion fish) \
|
|
|
|
--zsh <($out/bin/luarocks-admin completion zsh)
|
|
|
|
''
|
|
|
|
+ ''
|
2020-04-24 23:36:52 +00:00
|
|
|
for i in "$out"/bin/*; do
|
|
|
|
test -L "$i" || {
|
|
|
|
wrapProgram "$i" \
|
|
|
|
--suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?.lua" \
|
|
|
|
--suffix LUA_PATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \
|
|
|
|
--suffix LUA_CPATH ";" "$(echo "$out"/lib/lua/*/)?.so" \
|
2022-10-30 15:09:59 +00:00
|
|
|
--suffix LUA_CPATH ";" "$(echo "$out"/share/lua/*/)?/init.lua" \
|
2024-05-15 15:35:15 +00:00
|
|
|
--suffix PATH : ${lib.makeBinPath finalAttrs.propagatedBuildInputs}
|
2020-04-24 23:36:52 +00:00
|
|
|
}
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
propagatedBuildInputs = [ zip unzip cmake ];
|
|
|
|
|
|
|
|
# unpack hook for src.rock and rockspec files
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
# cmake is just to compile packages with "cmake" buildType, not luarocks itself
|
|
|
|
dontUseCmakeConfigure = true;
|
|
|
|
|
|
|
|
shellHook = ''
|
|
|
|
export PATH="src/bin:''${PATH:-}"
|
|
|
|
export LUA_PATH="src/?.lua;''${LUA_PATH:-}"
|
|
|
|
'';
|
|
|
|
|
2022-09-30 11:47:45 +00:00
|
|
|
disallowedReferences = lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
|
|
|
|
lua.luaOnBuild
|
|
|
|
];
|
|
|
|
|
2022-06-16 17:23:12 +00:00
|
|
|
passthru = {
|
2022-12-28 21:21:41 +00:00
|
|
|
updateScript = nix-update-script { };
|
2022-06-16 17:23:12 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2024-06-20 14:57:18 +00:00
|
|
|
description = "Package manager for Lua";
|
2022-10-30 15:09:59 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ raskin teto ];
|
2024-05-15 15:35:15 +00:00
|
|
|
mainProgram = "luarocks";
|
2020-04-24 23:36:52 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
|
|
|
downloadPage = "http://luarocks.org/releases/";
|
|
|
|
};
|
2022-10-30 15:09:59 +00:00
|
|
|
})
|