From 97d8492ac54aa9f22c9469e274dbc5345e6fbc1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6gler?= Date: Wed, 1 Dec 2021 20:39:14 +0100 Subject: [PATCH] sumneko-lua-language-server: Add darwin support --- .../sumneko-lua-language-server/default.nix | 36 +++++++++++++++---- 1 file changed, 29 insertions(+), 7 deletions(-) diff --git a/pkgs/development/tools/sumneko-lua-language-server/default.nix b/pkgs/development/tools/sumneko-lua-language-server/default.nix index d8916ce3e9a8..85cdb9d53b45 100644 --- a/pkgs/development/tools/sumneko-lua-language-server/default.nix +++ b/pkgs/development/tools/sumneko-lua-language-server/default.nix @@ -1,5 +1,7 @@ -{ lib, stdenv, fetchFromGitHub, ninja, makeWrapper }: - +{ lib, stdenv, fetchFromGitHub, ninja, makeWrapper, darwin }: +let + target = if stdenv.isDarwin then "macOS" else "Linux"; +in stdenv.mkDerivation rec { pname = "sumneko-lua-language-server"; version = "2.5.1"; @@ -17,12 +19,32 @@ stdenv.mkDerivation rec { makeWrapper ]; + buildInputs = lib.optionals stdenv.isDarwin [ + darwin.apple_sdk.frameworks.CoreFoundation + darwin.apple_sdk.frameworks.Foundation + ]; + preBuild = '' cd 3rd/luamake + '' + + lib.optionalString stdenv.isDarwin '' + # Needed for the test + export HOME=/var/empty + # 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++,' ''; ninjaFlags = [ - "-fcompile/ninja/linux.ninja" + "-fcompile/ninja/${lib.toLower target}.ninja" ]; postBuild = '' @@ -33,15 +55,15 @@ stdenv.mkDerivation rec { installPhase = '' runHook preInstall - install -Dt "$out"/share/lua-language-server/bin/Linux bin/Linux/lua-language-server - install -m644 -t "$out"/share/lua-language-server/bin/Linux bin/Linux/*.* + install -Dt "$out"/share/lua-language-server/bin/${target} bin/${target}/lua-language-server + install -m644 -t "$out"/share/lua-language-server/bin/${target} bin/${target}/*.* install -m644 -t "$out"/share/lua-language-server {debugger,main}.lua cp -r locale meta script "$out"/share/lua-language-server # necessary for --version to work: install -m644 -t "$out"/share/lua-language-server changelog.md - makeWrapper "$out"/share/lua-language-server/bin/Linux/lua-language-server \ + makeWrapper "$out"/share/lua-language-server/bin/${target}/lua-language-server \ $out/bin/lua-language-server \ --add-flags "-E $out/share/lua-language-server/main.lua \ --logpath='~/.cache/sumneko_lua/log' \ @@ -55,7 +77,7 @@ stdenv.mkDerivation rec { homepage = "https://github.com/sumneko/lua-language-server"; license = licenses.mit; maintainers = with maintainers; [ mjlbach ]; - platforms = platforms.linux; + platforms = platforms.linux ++ platforms.darwin; mainProgram = "lua-language-server"; }; }