Merge pull request #264098 from elohmeier/sqlite-vss

sqlite-vss: init at 0.1.2

authored by h7x4 and committed by GitHub 6de92461 301f4bfb

+94
+53
pkgs/by-name/sq/sqlite-vss/package.nix
··· 1 + { lib 2 + , cmake 3 + , faiss 4 + , fetchFromGitHub 5 + , gomp 6 + , llvmPackages 7 + , nlohmann_json 8 + , sqlite 9 + , stdenv 10 + }: 11 + 12 + stdenv.mkDerivation (finalAttrs: { 13 + pname = "sqlite-vss"; 14 + version = "0.1.2"; 15 + 16 + src = fetchFromGitHub { 17 + owner = "asg017"; 18 + repo = "sqlite-vss"; 19 + rev = "v${finalAttrs.version}"; 20 + hash = "sha256-cb9UlSUAZp8B5NpNDBvJ2+ung98gjVKLxrM2Ek9fOcs="; 21 + }; 22 + 23 + patches = [ ./use-nixpkgs-libs.patch ]; 24 + 25 + nativeBuildInputs = [ cmake ]; 26 + 27 + buildInputs = [ nlohmann_json faiss sqlite ] 28 + ++ lib.optional stdenv.isLinux gomp 29 + ++ lib.optional stdenv.isDarwin llvmPackages.openmp; 30 + 31 + SQLITE_VSS_CMAKE_VERSION = finalAttrs.version; 32 + 33 + installPhase = '' 34 + runHook preInstall 35 + 36 + install -Dm444 -t "$out/lib" \ 37 + "libsqlite_vector0${stdenv.hostPlatform.extensions.staticLibrary}" \ 38 + "libsqlite_vss0${stdenv.hostPlatform.extensions.staticLibrary}" \ 39 + "vector0${stdenv.hostPlatform.extensions.sharedLibrary}" \ 40 + "vss0${stdenv.hostPlatform.extensions.sharedLibrary}" 41 + 42 + runHook postInstall 43 + ''; 44 + 45 + meta = with lib;{ 46 + description = "SQLite extension for efficient vector search based on Faiss"; 47 + homepage = "https://github.com/asg017/sqlite-vss"; 48 + changelog = "https://github.com/asg017/sqlite-vss/releases/tag/v${finalAttrs.version}"; 49 + license = licenses.mit; 50 + maintainers = with maintainers; [ elohmeier ]; 51 + platforms = platforms.unix; 52 + }; 53 + })
+41
pkgs/by-name/sq/sqlite-vss/use-nixpkgs-libs.patch
··· 1 + diff --git a/CMakeLists.txt b/CMakeLists.txt 2 + index c59d993..5606b46 100644 3 + --- a/CMakeLists.txt 4 + +++ b/CMakeLists.txt 5 + @@ -18,15 +18,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON) 6 + option(FAISS_ENABLE_GPU "" OFF) 7 + option(FAISS_ENABLE_PYTHON "" OFF) 8 + option(BUILD_TESTING "" OFF) 9 + -add_subdirectory(./vendor/faiss) 10 + - 11 + -# vendor in SQLite amalgammation 12 + -include_directories(vendor/sqlite) 13 + -link_directories(BEFORE vendor/sqlite) 14 + +find_package(OpenMP REQUIRED) 15 + +find_package(faiss REQUIRED) 16 + 17 + # Adding nlohmann_json for json parsing 18 + set(JSON_BuildTests OFF CACHE INTERNAL "") 19 + -add_subdirectory(vendor/json) 20 + +find_package(nlohmann_json REQUIRED) 21 + 22 + # ================================== sqlite-vector ================================== # 23 + add_library(sqlite-vector SHARED src/sqlite-vector.cpp) 24 + @@ -49,7 +46,7 @@ target_compile_definitions(sqlite-vector-static PUBLIC SQLITE_CORE) 25 + # ================================== sqlite-vss ================================== # 26 + add_library(sqlite-vss SHARED src/sqlite-vss.cpp) 27 + target_link_libraries(sqlite-vss sqlite3) 28 + -target_link_libraries(sqlite-vss faiss_avx2) 29 + +target_link_libraries(sqlite-vss faiss) 30 + target_include_directories(sqlite-vss PUBLIC "${PROJECT_BINARY_DIR}") 31 + 32 + set_target_properties(sqlite-vss PROPERTIES PREFIX "") 33 + @@ -58,7 +55,7 @@ set_target_properties(sqlite-vss PROPERTIES OUTPUT_NAME "vss0") 34 + # ============================== sqlite-vss-static =============================== # 35 + add_library(sqlite-vss-static STATIC src/sqlite-vss.cpp) 36 + target_link_libraries(sqlite-vss-static PRIVATE sqlite3) 37 + -target_link_libraries(sqlite-vss-static PUBLIC faiss_avx2) 38 + +target_link_libraries(sqlite-vss-static PUBLIC faiss) 39 + target_link_options(sqlite-vss-static PRIVATE "-Wl,-all_load") 40 + target_include_directories(sqlite-vss-static PUBLIC "${PROJECT_BINARY_DIR}") 41 + set_target_properties(sqlite-vss-static PROPERTIES OUTPUT_NAME "sqlite_vss0")