2021-12-06 16:07:01 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, ninja, makeWrapper, darwin }:
|
|
|
|
let
|
|
|
|
target = if stdenv.isDarwin then "macOS" else "Linux";
|
|
|
|
in
|
2021-01-15 22:18:51 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sumneko-lua-language-server";
|
2022-05-18 14:49:53 +00:00
|
|
|
version = "3.2.3";
|
2021-01-15 22:18:51 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "sumneko";
|
|
|
|
repo = "lua-language-server";
|
|
|
|
rev = version;
|
2022-05-18 14:49:53 +00:00
|
|
|
sha256 = "sha256-n54PWkiB+vXAqIOZ5FOTUNgGhAdBs81Q1WYxJ2XIb8o=";
|
2021-01-15 22:18:51 +00:00
|
|
|
fetchSubmodules = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
ninja
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
buildInputs = lib.optionals stdenv.isDarwin [
|
|
|
|
darwin.apple_sdk.frameworks.CoreFoundation
|
|
|
|
darwin.apple_sdk.frameworks.Foundation
|
|
|
|
];
|
|
|
|
|
2022-05-18 14:49:53 +00:00
|
|
|
# Disable cwd support on x86 darwin, because it requires macOS>=10.15
|
|
|
|
preConfigure = lib.optionalString (stdenv.isDarwin && stdenv.isx86_64) ''
|
2022-04-27 09:35:20 +00:00
|
|
|
for file in 3rd/bee.lua/bee/subprocess/subprocess_posix.cpp 3rd/luamake/3rd/bee.lua/bee/subprocess/subprocess_posix.cpp; do
|
2022-05-18 14:49:53 +00:00
|
|
|
substituteInPlace $file --replace '#define USE_POSIX_SPAWN 1' ""
|
2022-04-27 09:35:20 +00:00
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
preBuild = ''
|
|
|
|
cd 3rd/luamake
|
2021-12-06 16:07:01 +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++,'
|
2021-01-15 22:18:51 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
ninjaFlags = [
|
2021-12-06 16:07:01 +00:00
|
|
|
"-fcompile/ninja/${lib.toLower target}.ninja"
|
2021-04-19 03:05:28 +00:00
|
|
|
];
|
2021-01-15 22:18:51 +00:00
|
|
|
|
|
|
|
postBuild = ''
|
|
|
|
cd ../..
|
|
|
|
./3rd/luamake/luamake rebuild
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-04-19 03:05:28 +00:00
|
|
|
runHook preInstall
|
|
|
|
|
2021-12-30 13:39:12 +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 16:52:03 +00:00
|
|
|
install -m644 -t "$out"/share/lua-language-server {debugger,main}.lua
|
|
|
|
cp -r locale meta script "$out"/share/lua-language-server
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
# necessary for --version to work:
|
|
|
|
install -m644 -t "$out"/share/lua-language-server changelog.md
|
|
|
|
|
2021-12-30 13:39:12 +00:00
|
|
|
makeWrapper "$out"/share/lua-language-server/bin/lua-language-server \
|
2021-01-15 22:18:51 +00:00
|
|
|
$out/bin/lua-language-server \
|
2021-10-11 16:52:03 +00:00
|
|
|
--add-flags "-E $out/share/lua-language-server/main.lua \
|
2021-01-15 22:18:51 +00:00
|
|
|
--logpath='~/.cache/sumneko_lua/log' \
|
|
|
|
--metapath='~/.cache/sumneko_lua/meta'"
|
2021-04-19 03:05:28 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2021-01-15 22:18:51 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2022-04-27 09:35:20 +00:00
|
|
|
description = "Lua Language Server coded by Lua";
|
2021-01-15 22:18:51 +00:00
|
|
|
homepage = "https://github.com/sumneko/lua-language-server";
|
|
|
|
license = licenses.mit;
|
2022-04-27 09:35:20 +00:00
|
|
|
maintainers = with maintainers; [ sei40kr ];
|
2021-12-06 16:07:01 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2021-09-28 08:13:01 +00:00
|
|
|
mainProgram = "lua-language-server";
|
2021-01-15 22:18:51 +00:00
|
|
|
};
|
|
|
|
}
|