diff --git a/pkgs/by-name/li/librum/package.nix b/pkgs/by-name/li/librum/package.nix new file mode 100644 index 000000000000..81cd81d68019 --- /dev/null +++ b/pkgs/by-name/li/librum/package.nix @@ -0,0 +1,68 @@ +{ lib +, mupdf +, stdenv +, fetchFromGitHub +, substituteAll +, cmake +, qt6 +, desktopToDarwinBundle +}: + +let + mupdf-cxx = mupdf.override { enableCxx = true; }; +in +stdenv.mkDerivation rec { + pname = "librum"; + version = "0.12.1"; + + src = fetchFromGitHub { + owner = "Librum-Reader"; + repo = "Librum"; + rev = "v.${version}"; + fetchSubmodules = true; + hash = "sha256-/QxTWlTMoXykPe3z+mmn6eaGRJDu2IX8BJPcXi1gUqQ="; + }; + + patches = [ + (substituteAll { + src = ./use_mupdf_in_nixpkgs.patch; + nixMupdfLibPath = "${mupdf-cxx.out}/lib"; + nixMupdfIncludePath = "${mupdf-cxx.dev}/include"; + }) + ]; + + nativeBuildInputs = [ + cmake + qt6.qttools + qt6.wrapQtAppsHook + ] ++ lib.optionals stdenv.isDarwin [ + desktopToDarwinBundle + ]; + + buildInputs = [ + qt6.qtbase + qt6.qtsvg + ] ++ lib.optionals stdenv.isLinux [ + qt6.qtwayland + ]; + + meta = with lib; { + description = "An application designed to make reading enjoyable and straightforward"; + longDescription = '' + Librum is an application designed to make reading enjoyable + and straightforward for everyone. It's not just an e-book + reader. With Librum, you can manage your own online library + and access it from any device anytime, anywhere. It has + features like note-taking, AI tooling, and highlighting, + while offering customization to make it as personal as you + want! Librum also provides free access to over 70,000 books + and personal reading statistics while being free and + completely open source. + ''; + homepage = "https://librumreader.com"; + license = licenses.gpl3Plus; + mainProgram = "librum"; + maintainers = with maintainers; [ aleksana oluceps ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/by-name/li/librum/use_mupdf_in_nixpkgs.patch b/pkgs/by-name/li/librum/use_mupdf_in_nixpkgs.patch new file mode 100644 index 000000000000..0458279b7d68 --- /dev/null +++ b/pkgs/by-name/li/librum/use_mupdf_in_nixpkgs.patch @@ -0,0 +1,109 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index 191ff732..de46f35b 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -71,7 +71,7 @@ endif() + + # Dependencies + add_subdirectory(libs/rapidfuzz-cpp) +- ++include_directories(@nixMupdfIncludePath@) + + # Build + add_subdirectory(src/) +diff --git a/src/application/CMakeLists.txt b/src/application/CMakeLists.txt +index bf122a66..64415be3 100644 +--- a/src/application/CMakeLists.txt ++++ b/src/application/CMakeLists.txt +@@ -102,10 +102,9 @@ if(ANDROID) + endif() + + if(UNIX) +- set(MUPDF_OUTPUT_DIR "${PROJECT_SOURCE_DIR}/libs/mupdf/build/$,shared-debug,shared-release>") ++ set(MUPDF_OUTPUT_DIR "@nixMupdfLibPath@") + set(MUPDF_OUTPUT "${MUPDF_OUTPUT_DIR}/libmupdfcpp.so") + set(MUPDF_OUTPUT "${MUPDF_OUTPUT_DIR}/libmupdfcpp.so" PARENT_SCOPE) +- set(MUPDF_BUILD_COMMAND ./scripts/mupdfwrap.py ${VENV_OPTION} -d build/$,shared-debug,shared-release> -b --m-target libs ${EXTRA_MAKE_AGRS} -j 0 m01) + elseif(WIN32) + set(MUPDF_OUTPUT_DIR "${PROJECT_SOURCE_DIR}/libs/mupdf/platform/win32/x64/$,Debug,Release>") + set(MUPDF_OUTPUT "${MUPDF_OUTPUT_DIR}/mupdfcpp64.lib" PARENT_SCOPE) +@@ -113,8 +112,6 @@ elseif(WIN32) + set(MUPDF_BUILD_COMMAND python scripts/mupdfwrap.py ${VENV_OPTION} -d build/$,shared-debug,shared-release> -b -j 0 m01) + endif() + +-message("MuPdf build command: " ${MUPDF_BUILD_COMMAND}) +- + + set(CC_COMMAND "${CMAKE_C_COMPILER}") + set(CXX_COMMAND "${CMAKE_CXX_COMPILER}") +@@ -135,18 +132,6 @@ else() + endif() + + +-add_custom_target(mupdf +- COMMAND ${CMAKE_COMMAND} -E env +- ${ANDROID_COMPILERS} +- "USE_SYSTEM_LIBJPEG=${USE_SYSTEM_LIBJPEG_VALUE}" +- "USE_SONAME=no" +- ${MUPDF_BUILD_COMMAND} +- BYPRODUCTS ${MUPDF_OUTPUT} +- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/libs/mupdf +- COMMENT "Building mupdf (This takes a while) ..." +-) +- +- + #Copy the mupdf dlls to the build directory for windows + if(WIN32) + add_custom_command( +@@ -168,8 +153,6 @@ add_library(application + interfaces/utility/i_book_getter.hpp + ) + +-add_dependencies(application mupdf) # Ensure the mupdf target is built before the application target +- + target_compile_definitions(application PRIVATE APPLICATION_LIBRARY) + + target_include_directories(application +@@ -188,12 +171,6 @@ target_include_directories(application + ${CMAKE_CURRENT_SOURCE_DIR}/core/utils + ) + +-# Make sure to ignore warnings from mupdf by adding it as a system include directory +-target_include_directories(application SYSTEM PUBLIC +- ${PROJECT_SOURCE_DIR}/libs/mupdf/platform/c++/include +- ${PROJECT_SOURCE_DIR}/libs/mupdf/include +-) +- + target_compile_definitions(application + PRIVATE + $<$,$>:QT_QML_DEBUG> +@@ -236,29 +213,10 @@ if(LINUX) + install(TARGETS application + DESTINATION lib + ) +- +- # Install mupdf's shared libraries +- install(FILES ${MUPDF_OUTPUT_DIR}/libmupdfcpp.so +- ${MUPDF_OUTPUT_DIR}/libmupdf.so +- DESTINATION lib) +- +- # Install links with correct permissions +- if(EXISTS "${MUPDF_OUTPUT_DIR}/libmupdfcpp.so.24.0") +- install(FILES ${MUPDF_OUTPUT_DIR}/libmupdfcpp.so.24.0 +- ${MUPDF_OUTPUT_DIR}/libmupdf.so.24.0 +- PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE +- GROUP_READ GROUP_EXECUTE +- WORLD_READ WORLD_EXECUTE +- DESTINATION lib) +- endif() + + elseif(APPLE) + install(TARGETS application + DESTINATION lib + ) + +- # Install mupdf's shared libraries +- install(FILES ${MUPDF_OUTPUT_DIR}/libmupdfcpp.so +- ${MUPDF_OUTPUT_DIR}/libmupdf.dylib +- DESTINATION lib) + endif()