Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at 23.11 92 lines 3.0 kB view raw
1{ lib, stdenv, fetchFromGitHub, ninja, makeWrapper, CoreFoundation, Foundation, ditto }: 2 3stdenv.mkDerivation rec { 4 pname = "lua-language-server"; 5 version = "3.7.3"; 6 7 src = fetchFromGitHub { 8 owner = "luals"; 9 repo = "lua-language-server"; 10 rev = version; 11 hash = "sha256-iAxRGG7/zaUbJ/PWgmjxGS0UTq9/OXc8RWzlpUTUftc="; 12 fetchSubmodules = true; 13 }; 14 15 nativeBuildInputs = [ 16 ninja 17 makeWrapper 18 ]; 19 20 buildInputs = lib.optionals stdenv.isDarwin [ 21 CoreFoundation 22 Foundation 23 ditto 24 ]; 25 26 postPatch = '' 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 30 31 pushd 3rd/luamake 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++,' 44 ''; 45 46 # Work around https://github.com/NixOS/nixpkgs/issues/166205. 47 env = lib.optionalAttrs stdenv.cc.isClang { 48 NIX_LDFLAGS = "-l${stdenv.cc.libcxx.cxxabi.libName}"; 49 }; 50 51 ninjaFlags = [ 52 "-fcompile/ninja/${if stdenv.isDarwin then "macos" else "linux"}.ninja" 53 ]; 54 55 postBuild = '' 56 popd 57 ./3rd/luamake/luamake rebuild 58 ''; 59 60 installPhase = '' 61 runHook preInstall 62 63 install -Dt "$out"/share/lua-language-server/bin bin/lua-language-server 64 install -m644 -t "$out"/share/lua-language-server/bin bin/*.* 65 install -m644 -t "$out"/share/lua-language-server {debugger,main}.lua 66 cp -r locale meta script "$out"/share/lua-language-server 67 68 # necessary for --version to work: 69 install -m644 -t "$out"/share/lua-language-server changelog.md 70 71 makeWrapper "$out"/share/lua-language-server/bin/lua-language-server \ 72 $out/bin/lua-language-server \ 73 --add-flags "-E $out/share/lua-language-server/main.lua \ 74 --logpath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/log \ 75 --metapath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/meta" 76 77 runHook postInstall 78 ''; 79 80 # some tests require local networking 81 __darwinAllowLocalNetworking = true; 82 83 meta = with lib; { 84 description = "A language server that offers Lua language support"; 85 homepage = "https://github.com/luals/lua-language-server"; 86 changelog = "https://github.com/LuaLS/lua-language-server/blob/${version}/changelog.md"; 87 license = licenses.mit; 88 maintainers = with maintainers; [ figsoda gepbird sei40kr ]; 89 mainProgram = "lua-language-server"; 90 platforms = platforms.linux ++ platforms.darwin; 91 }; 92}