nixpkgs/pkgs/by-name/hn/hnswlib/package.nix
aleksana 571c71e6f7 treewide: migrate packages to pkgs/by-name, take 1
We are migrating packages that meet below requirements:

1. using `callPackage`
2. called path is a directory
3. overriding set is empty (`{ }`)
4. not containing path expressions other than relative path (to
makenixpkgs-vet happy)
5. not referenced by nix files outside of the directory, other
than`pkgs/top-level/all-packages.nix`
6. not referencing nix files outside of the directory
7. not referencing `default.nix` (since it's changed to `package.nix`)
8. `outPath` doesn't change after migration

The tool is here: https://github.com/Aleksanaa/by-name-migrate.
2024-11-09 20:04:51 +08:00

67 lines
1.4 KiB
Nix

{ 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/${lib.removePrefix "refs/tags/" finalAttrs.src.rev}";
license = licenses.asl20;
maintainers = with maintainers; [ natsukium ];
platforms = platforms.unix;
};
})