about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/sq/sqlite-vss/package.nix
blob: b619e8ae6ed5e8e0d507eb3c416da91ce18722e6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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;
  };
})