1 { lib, stdenv, fetchFromGitHub, ninja, makeWrapper, CoreFoundation, Foundation, ditto }:
3 stdenv.mkDerivation rec {
4 pname = "lua-language-server";
7 src = fetchFromGitHub {
9 repo = "lua-language-server";
11 hash = "sha256-iAxRGG7/zaUbJ/PWgmjxGS0UTq9/OXc8RWzlpUTUftc=";
12 fetchSubmodules = true;
20 buildInputs = lib.optionals stdenv.isDarwin [
27 # filewatch tests are failing on darwin
28 # this feature is not used in lua-language-server
29 sed -i /filewatch/d 3rd/bee.lua/test/test.lua
32 '' + lib.optionalString stdenv.isDarwin ''
33 # This package uses the program clang for C and C++ files. The language
34 # is selected via the command line argument -std, but this do not work
35 # in combination with the nixpkgs clang wrapper. Therefor we have to
36 # find all c++ compiler statements and replace $cc (which expands to
37 # clang) with clang++.
38 sed -i compile/ninja/macos.ninja \
39 -e '/c++/s,$cc,clang++,' \
40 -e '/test.lua/s,= .*,= true,' \
41 -e '/ldl/s,$cc,clang++,'
42 sed -i scripts/compiler/gcc.lua \
43 -e '/cxx_/s,$cc,clang++,'
47 "-fcompile/ninja/${if stdenv.isDarwin then "macos" else "linux"}.ninja"
52 ./3rd/luamake/luamake rebuild
58 install -Dt "$out"/share/lua-language-server/bin bin/lua-language-server
59 install -m644 -t "$out"/share/lua-language-server/bin bin/*.*
60 install -m644 -t "$out"/share/lua-language-server {debugger,main}.lua
61 cp -r locale meta script "$out"/share/lua-language-server
63 # necessary for --version to work:
64 install -m644 -t "$out"/share/lua-language-server changelog.md
66 makeWrapper "$out"/share/lua-language-server/bin/lua-language-server \
67 $out/bin/lua-language-server \
68 --add-flags "-E $out/share/lua-language-server/main.lua \
69 --logpath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/log \
70 --metapath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/meta"
75 # some tests require local networking
76 __darwinAllowLocalNetworking = true;
79 description = "A language server that offers Lua language support";
80 homepage = "https://github.com/luals/lua-language-server";
81 changelog = "https://github.com/LuaLS/lua-language-server/blob/${version}/changelog.md";
82 license = licenses.mit;
83 maintainers = with maintainers; [ figsoda gepbird sei40kr ];
84 mainProgram = "lua-language-server";
85 platforms = platforms.linux ++ platforms.darwin;