about summary refs log tree commit diff
path: root/pkgs/development/tools/luaformatter
diff options
context:
space:
mode:
authorSandro Jäckel <sandro.jaeckel@gmail.com>2021-08-18 23:17:58 +0200
committerSandro Jäckel <sandro.jaeckel@gmail.com>2021-08-18 23:23:09 +0200
commit6dd3bfff7af4ab458a262d0950eb012b9acfd31a (patch)
tree7d38c35e539f1baf589eaa2bfca4ea76143d4686 /pkgs/development/tools/luaformatter
parent100233eab6ff204039bfe7eabab1ec18ba4b685a (diff)
luaformatter: combine with duplicate package lua-format, remove submodule usage
Diffstat (limited to 'pkgs/development/tools/luaformatter')
-rw-r--r--pkgs/development/tools/luaformatter/default.nix30
-rw-r--r--pkgs/development/tools/luaformatter/fix-lib-paths.patch67
2 files changed, 83 insertions, 14 deletions
diff --git a/pkgs/development/tools/luaformatter/default.nix b/pkgs/development/tools/luaformatter/default.nix
index 2745e7e01b132..5fb82b0fb4c91 100644
--- a/pkgs/development/tools/luaformatter/default.nix
+++ b/pkgs/development/tools/luaformatter/default.nix
@@ -1,31 +1,33 @@
-{ cmake, fetchFromGitHub, lib, stdenv }:
+{ lib, stdenv, fetchFromGitHub, substituteAll, antlr4, libargs, catch2, cmake, libyamlcpp }:
 
 stdenv.mkDerivation rec {
   pname = "luaformatter";
   version = "1.3.6";
 
   src = fetchFromGitHub {
-    owner = "koihik";
-    repo = "luaformatter";
+    owner = "Koihik";
+    repo = "LuaFormatter";
     rev = version;
-    sha256 = "0440kdab5i0vhlk71sbprdrhg362al8jqpy7w2vdhcz1fpi5cm0b";
-    fetchSubmodules = true;
+    sha256 = "14l1f9hrp6m7z3cm5yl0njba6gfixzdirxjl8nihp9val0685vm0";
   };
 
+  patches = [
+    (substituteAll {
+      src = ./fix-lib-paths.patch;
+      antlr4RuntimeCpp = antlr4.runtime.cpp.dev;
+      inherit libargs catch2 libyamlcpp;
+    })
+  ];
+
   nativeBuildInputs = [ cmake ];
 
-  installPhase = ''
-    runHook preInstall
-    mkdir -p $out/bin
-    cp lua-format $out/bin
-    runHook postInstall
-  '';
+  buildInputs = [ antlr4.runtime.cpp libyamlcpp ];
 
   meta = with lib; {
-    description = "Code formatter for lua";
-    homepage = "https://github.com/koihik/luaformatter";
+    description = "Code formatter for Lua";
+    homepage = "https://github.com/Koihik/LuaFormatter";
     license = licenses.asl20;
-    maintainers = with maintainers; [ figsoda ];
+    maintainers = with maintainers; [ figsoda SuperSandro2000 ];
     mainProgram = "lua-format";
   };
 }
diff --git a/pkgs/development/tools/luaformatter/fix-lib-paths.patch b/pkgs/development/tools/luaformatter/fix-lib-paths.patch
new file mode 100644
index 0000000000000..fce2347d8e0e8
--- /dev/null
+++ b/pkgs/development/tools/luaformatter/fix-lib-paths.patch
@@ -0,0 +1,67 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 4a21b94..0ac7911 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -67,10 +67,10 @@ endif()
+ 
+ include_directories(
+   ${PROJECT_SOURCE_DIR}/generated/
+-  ${PROJECT_SOURCE_DIR}/third_party/
+-  ${PROJECT_SOURCE_DIR}/third_party/Catch2/single_include
+-  ${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/include
+-  ${PROJECT_SOURCE_DIR}/third_party/antlr4/runtime/Cpp/runtime/src
++  @libargs@/include
++  @catch2@/include
++  @libyamlcpp@/include
++  @antlr4RuntimeCpp@/include/antlr4-runtime
+   ${PROJECT_SOURCE_DIR}/src/
+   )
+ 
+@@ -92,9 +92,6 @@ file(GLOB_RECURSE yaml-cpp-src
+   ${PROJECT_SOURCE_DIR}/third_party/yaml-cpp/src/*.cpp
+   )
+ 
+-add_library (antlr4-cpp-runtime ${antlr4-cpp-src})
+-add_library (yaml-cpp ${yaml-cpp-src})
+-
+ add_executable(lua-format ${src_dir} src/main.cpp)
+ 
+ if(WIN32)
+@@ -104,7 +101,7 @@ endif()
+ 
+ set_target_properties(lua-format PROPERTIES LINKER_LANGUAGE CXX)
+ 
+-target_link_libraries(lua-format yaml-cpp antlr4-cpp-runtime ${extra-libs})
++target_link_libraries(lua-format yaml-cpp antlr4-runtime ${extra-libs})
+ 
+ install(TARGETS lua-format
+   RUNTIME DESTINATION bin
+@@ -135,7 +132,7 @@ if(BUILD_TESTS)
+   endif()
+ 
+   target_compile_definitions(lua-format-test PUBLIC PROJECT_PATH="${PROJECT_SOURCE_DIR}")
+-  target_link_libraries(lua-format-test yaml-cpp antlr4-cpp-runtime ${extra-libs})
++  target_link_libraries(lua-format-test yaml-cpp antlr4-runtime ${extra-libs})
+ 
+   add_test(NAME args COMMAND lua-format-test [args])
+   add_test(NAME config COMMAND lua-format-test [config])
+diff --git a/src/main.cpp b/src/main.cpp
+index 38962a2..332aad6 100644
+--- a/src/main.cpp
++++ b/src/main.cpp
+@@ -1,4 +1,4 @@
+-#include <args/args.hxx>
++#include <args.hxx>
+ #include <cstdlib>
+ #include <fstream>
+ #include <iostream>
+diff --git a/test/test_args.cpp b/test/test_args.cpp
+index 69a5746..b988d00 100644
+--- a/test/test_args.cpp
++++ b/test/test_args.cpp
+@@ -1,4 +1,4 @@
+-#include <args/args.hxx>
++#include <args.hxx>
+ #include <catch2/catch.hpp>
+ #include <iostream>
+ #include <tuple>