about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/hnswlib/default.nix
blob: 4c5e4623776048fd064e97f51a0975f72c9ca1a7 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
{ lib
, stdenv
, fetchFromGitHub
, cmake
, python3
}:
let
  python = python3.withPackages(ps: with ps; [
    numpy
  ]);
in

stdenv.mkDerivation (finalAttrs: {
  pname = "hnswlib";
  version = "0.8.0";

  src = fetchFromGitHub {
    owner = "nmslib";
    repo = "hnswlib";
    rev = "refs/tags/v${finalAttrs.version}";
    hash = "sha256-1KkAX42j/I06KO4wCnDsDifN1JiENqYKR5NNHBjyuVA=";
  };

  # this is a header-only library, so we don't need to build it
  # we need `cmake` only to run tests
  nativeCheckInputs = [
    cmake
    python
  ];

  # we only want to run buildPhase when we run tests
  dontBuild = !finalAttrs.finalPackage.doCheck;

  installPhase = ''
    runHook preInstall

    install -Dm644 $src/hnswlib/*.h -t $out/include/hnswlib

    runHook postInstall
  '';

  doCheck = true;

  preCheck = ''
    pushd ../tests/cpp
    ${python.interpreter} update_gen_data.py
    popd
  '';

  checkPhase = ''
    runHook preCheck

    ./test_updates

    runHook postCheck
  '';

  meta = with lib; {
    description = "Header-only C++/python library for fast approximate nearest neighbors";
    homepage = "https://github.com/nmslib/hnswlib";
    changelog = "https://github.com/nmslib/hnswlib/releases/tag/${finalAttrs.src.rev}";
    license = licenses.asl20;
    maintainers = with maintainers; [ natsukium ];
    platforms = platforms.unix;
  };
})