Merge pull request #264098 from elohmeier/sqlite-vss
sqlite-vss: init at 0.1.2
This commit is contained in:
commit
6de924611b
53
pkgs/by-name/sq/sqlite-vss/package.nix
Normal file
53
pkgs/by-name/sq/sqlite-vss/package.nix
Normal file
@ -0,0 +1,53 @@
|
||||
{ lib
|
||||
, cmake
|
||||
, faiss
|
||||
, fetchFromGitHub
|
||||
, gomp
|
||||
, llvmPackages
|
||||
, nlohmann_json
|
||||
, sqlite
|
||||
, stdenv
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "sqlite-vss";
|
||||
version = "0.1.2";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "asg017";
|
||||
repo = "sqlite-vss";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-cb9UlSUAZp8B5NpNDBvJ2+ung98gjVKLxrM2Ek9fOcs=";
|
||||
};
|
||||
|
||||
patches = [ ./use-nixpkgs-libs.patch ];
|
||||
|
||||
nativeBuildInputs = [ cmake ];
|
||||
|
||||
buildInputs = [ nlohmann_json faiss sqlite ]
|
||||
++ lib.optional stdenv.isLinux gomp
|
||||
++ lib.optional stdenv.isDarwin llvmPackages.openmp;
|
||||
|
||||
SQLITE_VSS_CMAKE_VERSION = finalAttrs.version;
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
|
||||
install -Dm444 -t "$out/lib" \
|
||||
"libsqlite_vector0${stdenv.hostPlatform.extensions.staticLibrary}" \
|
||||
"libsqlite_vss0${stdenv.hostPlatform.extensions.staticLibrary}" \
|
||||
"vector0${stdenv.hostPlatform.extensions.sharedLibrary}" \
|
||||
"vss0${stdenv.hostPlatform.extensions.sharedLibrary}"
|
||||
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = with lib;{
|
||||
description = "SQLite extension for efficient vector search based on Faiss";
|
||||
homepage = "https://github.com/asg017/sqlite-vss";
|
||||
changelog = "https://github.com/asg017/sqlite-vss/releases/tag/v${finalAttrs.version}";
|
||||
license = licenses.mit;
|
||||
maintainers = with maintainers; [ elohmeier ];
|
||||
platforms = platforms.unix;
|
||||
};
|
||||
})
|
41
pkgs/by-name/sq/sqlite-vss/use-nixpkgs-libs.patch
Normal file
41
pkgs/by-name/sq/sqlite-vss/use-nixpkgs-libs.patch
Normal file
@ -0,0 +1,41 @@
|
||||
diff --git a/CMakeLists.txt b/CMakeLists.txt
|
||||
index c59d993..5606b46 100644
|
||||
--- a/CMakeLists.txt
|
||||
+++ b/CMakeLists.txt
|
||||
@@ -18,15 +18,12 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||
option(FAISS_ENABLE_GPU "" OFF)
|
||||
option(FAISS_ENABLE_PYTHON "" OFF)
|
||||
option(BUILD_TESTING "" OFF)
|
||||
-add_subdirectory(./vendor/faiss)
|
||||
-
|
||||
-# vendor in SQLite amalgammation
|
||||
-include_directories(vendor/sqlite)
|
||||
-link_directories(BEFORE vendor/sqlite)
|
||||
+find_package(OpenMP REQUIRED)
|
||||
+find_package(faiss REQUIRED)
|
||||
|
||||
# Adding nlohmann_json for json parsing
|
||||
set(JSON_BuildTests OFF CACHE INTERNAL "")
|
||||
-add_subdirectory(vendor/json)
|
||||
+find_package(nlohmann_json REQUIRED)
|
||||
|
||||
# ================================== sqlite-vector ================================== #
|
||||
add_library(sqlite-vector SHARED src/sqlite-vector.cpp)
|
||||
@@ -49,7 +46,7 @@ target_compile_definitions(sqlite-vector-static PUBLIC SQLITE_CORE)
|
||||
# ================================== sqlite-vss ================================== #
|
||||
add_library(sqlite-vss SHARED src/sqlite-vss.cpp)
|
||||
target_link_libraries(sqlite-vss sqlite3)
|
||||
-target_link_libraries(sqlite-vss faiss_avx2)
|
||||
+target_link_libraries(sqlite-vss faiss)
|
||||
target_include_directories(sqlite-vss PUBLIC "${PROJECT_BINARY_DIR}")
|
||||
|
||||
set_target_properties(sqlite-vss PROPERTIES PREFIX "")
|
||||
@@ -58,7 +55,7 @@ set_target_properties(sqlite-vss PROPERTIES OUTPUT_NAME "vss0")
|
||||
# ============================== sqlite-vss-static =============================== #
|
||||
add_library(sqlite-vss-static STATIC src/sqlite-vss.cpp)
|
||||
target_link_libraries(sqlite-vss-static PRIVATE sqlite3)
|
||||
-target_link_libraries(sqlite-vss-static PUBLIC faiss_avx2)
|
||||
+target_link_libraries(sqlite-vss-static PUBLIC faiss)
|
||||
target_link_options(sqlite-vss-static PRIVATE "-Wl,-all_load")
|
||||
target_include_directories(sqlite-vss-static PUBLIC "${PROJECT_BINARY_DIR}")
|
||||
set_target_properties(sqlite-vss-static PROPERTIES OUTPUT_NAME "sqlite_vss0")
|
Loading…
Reference in New Issue
Block a user