2021-12-01 19:39:14 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, ninja, makeWrapper, darwin }:
|
|
|
|
let
|
|
|
|
target = if stdenv.isDarwin then "macOS" else "Linux";
|
|
|
|
in
|
2020-12-30 01:30:18 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sumneko-lua-language-server";
|
2022-04-25 17:05:41 +00:00
|
|
|
version = "3.2.1";
|
2020-12-30 01:30:18 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "sumneko";
|
|
|
|
repo = "lua-language-server";
|
|
|
|
rev = version;
|
2022-04-25 17:05:41 +00:00
|
|
|
sha256 = "sha256-rxferVxTWmclviDshHhBmbCezOI+FvcfUW3gAkBQNHQ=";
|
2020-12-30 01:30:18 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
ninja
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
2021-12-01 19:39:14 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.CoreFoundation
|
|
|
|
darwin.apple_sdk.frameworks.Foundation
|
|
|
|
];
|
|
|
|
|
2022-04-23 04:20:00 +00:00
|
|
|
# Disable cwd support on darwin, because it requires macOS>=10.15
|
|
|
|
preConfigure = lib.optionalString stdenv.isDarwin ''
|
|
|
|
for file in 3rd/bee.lua/bee/subprocess/subprocess_posix.cpp 3rd/luamake/3rd/bee.lua/bee/subprocess/subprocess_posix.cpp; do
|
|
|
|
substituteInPlace $file --replace '#define SUPPORT_CWD 1' ""
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2020-12-30 01:30:18 +00:00
|
|
|
preBuild = ''
|
|
|
|
cd 3rd/luamake
|
2021-12-01 19:39:14 +00:00
|
|
|
''
|
|
|
|
+ lib.optionalString stdenv.isDarwin ''
|
|
|
|
# Needed for the test
|
|
|
|
export HOME=/var/empty
|
|
|
|
# This package uses the program clang for C and C++ files. The language
|
|
|
|
# is selected via the command line argument -std, but this do not work
|
|
|
|
# in combination with the nixpkgs clang wrapper. Therefor we have to
|
|
|
|
# find all c++ compiler statements and replace $cc (which expands to
|
|
|
|
# clang) with clang++.
|
|
|
|
sed -i compile/ninja/macos.ninja \
|
|
|
|
-e '/c++/s,$cc,clang++,' \
|
|
|
|
-e '/test.lua/s,= .*,= true,' \
|
|
|
|
-e '/ldl/s,$cc,clang++,'
|
|
|
|
sed -i scripts/compiler/gcc.lua \
|
|
|
|
-e '/cxx_/s,$cc,clang++,'
|
2020-12-30 01:30:18 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
ninjaFlags = [
|
2021-12-01 19:39:14 +00:00
|
|
|
"-fcompile/ninja/${lib.toLower target}.ninja"
|
2021-04-18 13:19:13 +00:00
|
|
|
];
|
2020-12-30 01:30:18 +00:00
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
cd ../..
|
|
|
|
./3rd/luamake/luamake rebuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-04-18 13:19:13 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2021-12-27 17:02:25 +00:00
|
|
|
install -Dt "$out"/share/lua-language-server/bin bin/lua-language-server
|
|
|
|
install -m644 -t "$out"/share/lua-language-server/bin bin/*.*
|
2021-10-11 06:17:51 +00:00
|
|
|
install -m644 -t "$out"/share/lua-language-server {debugger,main}.lua
|
|
|
|
cp -r locale meta script "$out"/share/lua-language-server
|
|
|
|
|
2021-11-05 10:48:02 +00:00
|
|
|
# necessary for --version to work:
|
|
|
|
install -m644 -t "$out"/share/lua-language-server changelog.md
|
|
|
|
|
2021-12-27 17:02:25 +00:00
|
|
|
makeWrapper "$out"/share/lua-language-server/bin/lua-language-server \
|
2020-12-30 01:30:18 +00:00
|
|
|
$out/bin/lua-language-server \
|
2021-10-11 06:17:51 +00:00
|
|
|
--add-flags "-E $out/share/lua-language-server/main.lua \
|
2020-12-30 01:30:18 +00:00
|
|
|
--logpath='~/.cache/sumneko_lua/log' \
|
|
|
|
--metapath='~/.cache/sumneko_lua/meta'"
|
2021-04-18 13:19:13 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-12-30 01:30:18 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
meta = with lib; {
|
2022-04-16 14:52:05 +00:00
|
|
|
description = "Lua Language Server coded by Lua";
|
2020-12-30 01:30:18 +00:00
|
|
|
homepage = "https://github.com/sumneko/lua-language-server";
|
|
|
|
license = licenses.mit;
|
2022-04-16 14:52:05 +00:00
|
|
|
maintainers = with maintainers; [ sei40kr ];
|
2021-12-01 19:39:14 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2021-09-26 23:56:13 +00:00
|
|
|
mainProgram = "lua-language-server";
|
2020-12-30 01:30:18 +00:00
|
|
|
};
|
|
|
|
}
|