{ buildPgrxExtension, cargo-pgrx_0_16_1, postgresql, fetchFromGitHub, lib, postgresqlTestExtension, }: buildPgrxExtension (finalAttrs: { pname = "pgvectorscale"; version = "0.9.1"; src = fetchFromGitHub { owner = "timescale"; repo = "pgvectorscale"; tag = finalAttrs.version; hash = "sha256-4i5PhGfvfMPMhkmxfxvaWdIvmGHR1ZkMQzBSTNvqEgw="; }; doCheck = false; cargoHash = "sha256-2QmOxRKVkC/WBz6BRnxD57hH2E5ANHtNKrp/ytBaILI="; cargoPatches = [ ./add-Cargo.lock.patch ]; cargoPgrxFlags = [ "-p" "vectorscale" ]; inherit postgresql; cargo-pgrx = cargo-pgrx_0_16_1; passthru.tests.extension = postgresqlTestExtension { inherit (finalAttrs) finalPackage; withPackages = [ "pgvector" ]; sql = '' CREATE EXTENSION vectorscale CASCADE; CREATE TABLE document_embedding ( id BIGINT PRIMARY KEY GENERATED BY DEFAULT AS IDENTITY, embedding VECTOR(3) ); INSERT INTO document_embedding (id, embedding) VALUES (10, '[1,2,4]'), (20, '[1,2,5]'); CREATE INDEX document_embedding_idx ON document_embedding USING diskann (embedding vector_cosine_ops); ''; asserts = [ { query = "SELECT id FROM document_embedding WHERE embedding <-> '[1,2,3]' = 1"; expected = "10"; description = "Expected vector of row with ID=10 to have an euclidean distance from [1,2,3] of 1."; } { query = "SELECT id FROM document_embedding WHERE embedding <-> '[1,2,3]' = 2"; expected = "20"; description = "Expected vector of row with ID=20 to have an euclidean distance from [1,2,3] of 2."; } ]; }; meta = { # PostgreSQL 19 is not yet supported # See https://github.com/timescale/pgvectorscale/issues/281 # Check after next package update. broken = lib.warnIf (finalAttrs.version != "0.9.1") "Is postgresql19Packages.pgvectorscale still broken?" (lib.versionAtLeast postgresql.version "19"); homepage = "https://github.com/timescale/pgvectorscale"; maintainers = [ lib.maintainers.leona lib.maintainers.osnyx ]; description = "Complement to pgvector for high performance, cost efficient vector search on large workloads"; license = lib.licenses.postgresql; platforms = postgresql.meta.platforms; changelog = "https://github.com/timescale/pgvectorscale/releases/tag/${finalAttrs.version}"; }; })