2023-07-23 06:12:04 +00:00
|
|
|
{ lib, stdenv, fetchFromGitHub, ninja, makeWrapper, CoreFoundation, Foundation, ditto }:
|
2023-02-07 03:43:34 +00:00
|
|
|
|
2024-01-05 12:56:31 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2023-02-07 03:43:34 +00:00
|
|
|
pname = "lua-language-server";
|
2024-01-05 12:56:31 +00:00
|
|
|
version = "3.7.4";
|
2020-12-30 01:30:18 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2023-02-07 03:23:53 +00:00
|
|
|
owner = "luals";
|
2020-12-30 01:30:18 +00:00
|
|
|
repo = "lua-language-server";
|
2024-01-05 12:56:31 +00:00
|
|
|
rev = finalAttrs.version;
|
|
|
|
hash = "sha256-wJOOzKM2pgxfRqx5WZjOcCyRapz0Sub3AYm51LRYpFU=";
|
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 [
|
2022-07-10 08:45:54 +00:00
|
|
|
CoreFoundation
|
|
|
|
Foundation
|
2023-07-23 06:12:04 +00:00
|
|
|
ditto
|
2021-12-01 19:39:14 +00:00
|
|
|
];
|
|
|
|
|
2023-02-07 03:23:53 +00:00
|
|
|
postPatch = ''
|
|
|
|
# filewatch tests are failing on darwin
|
|
|
|
# this feature is not used in lua-language-server
|
|
|
|
sed -i /filewatch/d 3rd/bee.lua/test/test.lua
|
|
|
|
|
|
|
|
pushd 3rd/luamake
|
|
|
|
'' + lib.optionalString stdenv.isDarwin ''
|
2021-12-01 19:39:14 +00:00
|
|
|
# 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
|
|
|
'';
|
|
|
|
|
2023-11-19 20:52:11 +00:00
|
|
|
# Work around https://github.com/NixOS/nixpkgs/issues/166205.
|
|
|
|
env = lib.optionalAttrs stdenv.cc.isClang {
|
|
|
|
NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}";
|
|
|
|
};
|
|
|
|
|
2020-12-30 01:30:18 +00:00
|
|
|
ninjaFlags = [
|
2023-02-07 03:43:34 +00:00
|
|
|
"-fcompile/ninja/${if stdenv.isDarwin then "macos" else "linux"}.ninja"
|
2021-04-18 13:19:13 +00:00
|
|
|
];
|
2020-12-30 01:30:18 +00:00
|
|
|
|
|
|
|
postBuild = ''
|
2023-02-07 03:23:53 +00:00
|
|
|
popd
|
2020-12-30 01:30:18 +00:00
|
|
|
./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 \
|
2023-02-07 03:43:34 +00:00
|
|
|
--logpath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/log \
|
|
|
|
--metapath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/meta"
|
2021-04-18 13:19:13 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
2020-12-30 01:30:18 +00:00
|
|
|
'';
|
|
|
|
|
2023-02-07 03:23:53 +00:00
|
|
|
# some tests require local networking
|
|
|
|
__darwinAllowLocalNetworking = true;
|
|
|
|
|
2021-01-23 12:26:19 +00:00
|
|
|
meta = with lib; {
|
2023-02-07 03:43:34 +00:00
|
|
|
description = "A language server that offers Lua language support";
|
2023-02-07 03:23:53 +00:00
|
|
|
homepage = "https://github.com/luals/lua-language-server";
|
2023-02-13 14:55:02 +00:00
|
|
|
changelog = "https://github.com/LuaLS/lua-language-server/blob/${version}/changelog.md";
|
2020-12-30 01:30:18 +00:00
|
|
|
license = licenses.mit;
|
2023-11-12 13:01:00 +00:00
|
|
|
maintainers = with maintainers; [ figsoda gepbird sei40kr ];
|
2023-08-24 14:21:27 +00:00
|
|
|
mainProgram = "lua-language-server";
|
2021-12-01 19:39:14 +00:00
|
|
|
platforms = platforms.linux ++ platforms.darwin;
|
2020-12-30 01:30:18 +00:00
|
|
|
};
|
2024-01-05 12:56:31 +00:00
|
|
|
})
|