nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 144 lines 3.9 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 6 # nativeBuildInputs 7 ninja, 8 makeWrapper, 9 10 # buildInputs 11 fmt, 12 libbfd, 13 libunwind, 14 rsync, 15 16 versionCheckHook, 17 nix-update-script, 18}: 19 20stdenv.mkDerivation (finalAttrs: { 21 pname = "lua-language-server"; 22 version = "3.17.1"; 23 24 src = fetchFromGitHub { 25 owner = "luals"; 26 repo = "lua-language-server"; 27 tag = finalAttrs.version; 28 hash = "sha256-NfxBiXiGF4+meXTwp6We9+bmHW7Z9ZcxvRXAGwWAULo="; 29 fetchSubmodules = true; 30 }; 31 32 nativeBuildInputs = [ 33 ninja 34 makeWrapper 35 ]; 36 37 buildInputs = [ 38 fmt 39 libbfd 40 libunwind 41 ] 42 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 43 rsync 44 ]; 45 46 env.NIX_LDFLAGS = "-lfmt"; 47 48 postPatch = '' 49 # filewatch tests are failing on darwin 50 # this feature is not used in lua-language-server 51 substituteInPlace 3rd/bee.lua/test/test.lua \ 52 --replace-fail 'require "test_filewatch"' "" 53 54 # use nixpkgs fmt library 55 for d in 3rd/bee.lua 3rd/luamake/bee.lua 56 do 57 rm -r $d/3rd/fmt/* 58 touch $d/3rd/fmt/format.cc 59 substituteInPlace $d/bee/nonstd/format.h $d/bee/nonstd/print.h \ 60 --replace-fail "include <3rd/fmt/fmt" "include <fmt" 61 done 62 63 # flaky tests on linux 64 # https://github.com/LuaLS/lua-language-server/issues/2926 65 substituteInPlace test/tclient/init.lua \ 66 --replace-fail "require 'tclient.tests.load-relative-library'" "" 67 68 pushd 3rd/luamake 69 '' 70 + lib.optionalString stdenv.hostPlatform.isDarwin ( 71 # This package uses the program clang for C and C++ files. The language 72 # is selected via the command line argument -std, but this do not work 73 # in combination with the nixpkgs clang wrapper. Therefor we have to 74 # find all c++ compiler statements and replace $cc (which expands to 75 # clang) with clang++. 76 '' 77 sed -i compile/ninja/macos.ninja \ 78 -e '/c++/s,$cc,clang++,' \ 79 -e '/test.lua/s,= .*,= true,' \ 80 -e '/ldl/s,$cc,clang++,' 81 sed -i scripts/compiler/gcc.lua \ 82 -e '/cxx_/s,$cc,clang++,' 83 '' 84 # Avoid relying on ditto (impure) 85 + '' 86 substituteInPlace compile/ninja/macos.ninja \ 87 --replace-fail "ditto" "rsync -a" 88 89 substituteInPlace scripts/writer.lua \ 90 --replace-fail "ditto" "rsync -a" 91 '' 92 ); 93 94 ninjaFlags = [ 95 "-fcompile/ninja/${if stdenv.hostPlatform.isDarwin then "macos" else "linux"}.ninja" 96 ]; 97 98 postBuild = '' 99 popd 100 ./3rd/luamake/luamake rebuild 101 ''; 102 103 installPhase = '' 104 runHook preInstall 105 106 install -Dt "$out"/share/lua-language-server/bin bin/lua-language-server 107 install -m644 -t "$out"/share/lua-language-server/bin bin/*.* 108 install -m644 -t "$out"/share/lua-language-server {debugger,main}.lua 109 cp -r locale meta script "$out"/share/lua-language-server 110 111 # necessary for --version to work: 112 install -m644 -t "$out"/share/lua-language-server changelog.md 113 114 makeWrapper "$out"/share/lua-language-server/bin/lua-language-server \ 115 $out/bin/lua-language-server \ 116 --add-flags "-E $out/share/lua-language-server/main.lua \ 117 --logpath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/log \ 118 --metapath=\''${XDG_CACHE_HOME:-\$HOME/.cache}/lua-language-server/meta" 119 120 runHook postInstall 121 ''; 122 123 # some tests require local networking 124 __darwinAllowLocalNetworking = true; 125 126 nativeInstallCheckInputs = [ 127 versionCheckHook 128 ]; 129 doInstallCheck = true; 130 131 passthru.updateScript = nix-update-script { }; 132 133 meta = { 134 description = "Language server that offers Lua language support"; 135 homepage = "https://github.com/luals/lua-language-server"; 136 changelog = "https://github.com/LuaLS/lua-language-server/blob/${finalAttrs.version}/changelog.md"; 137 license = lib.licenses.mit; 138 maintainers = with lib.maintainers; [ 139 gepbird 140 ]; 141 mainProgram = "lua-language-server"; 142 platforms = lib.platforms.linux ++ lib.platforms.darwin; 143 }; 144})