1 { lib, stdenv, fetchFromGitHub, ninja, makeWrapper, CoreFoundation, Foundation }:
3 target = if stdenv.isDarwin then "macOS" else "Linux";
5 stdenv.mkDerivation rec {
6 pname = "sumneko-lua-language-server";
9 src = fetchFromGitHub {
11 repo = "lua-language-server";
13 sha256 = "sha256-jlx2Tn5NuHq7OFHPHOknZfLAbQanWLMTsw7wO1SJOkk=";
14 fetchSubmodules = true;
22 buildInputs = lib.optionals stdenv.isDarwin [
30 + lib.optionalString stdenv.isDarwin ''
32 export HOME=/var/empty
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/${lib.toLower target}.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}/sumneko_lua/log \
70 --metapath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/sumneko_lua/meta"
76 description = "Lua Language Server coded by Lua";
77 homepage = "https://github.com/sumneko/lua-language-server";
78 license = licenses.mit;
79 maintainers = with maintainers; [ sei40kr ];
80 platforms = platforms.linux ++ platforms.darwin;
81 mainProgram = "lua-language-server";