pgvecto.rs: init at 0.2.1
Co-Authored-By: Daniel Albert <git@esclear.de> Co-Authored-By: rina <k@rina.fyi>
This commit is contained in:
parent
72e550dbcc
commit
3060321978
4 changed files with 3759 additions and 0 deletions
|
@ -0,0 +1,19 @@
|
|||
diff --git a/crates/c/build.rs b/crates/c/build.rs
|
||||
index 8d822e5..8b7e371 100644
|
||||
--- a/crates/c/build.rs
|
||||
+++ b/crates/c/build.rs
|
||||
@@ -1,9 +1,13 @@
|
||||
fn main() {
|
||||
println!("cargo:rerun-if-changed=src/c.h");
|
||||
println!("cargo:rerun-if-changed=src/c.c");
|
||||
+ println!("cargo:rerun-if-env-changed=BINDGEN_EXTRA_CLANG_ARGS");
|
||||
cc::Build::new()
|
||||
- .compiler("clang-16")
|
||||
+ .compiler("@clang@")
|
||||
.file("./src/c.c")
|
||||
+ // read env var set by rustPlatform.bindgenHook
|
||||
+ .try_flags_from_environment("BINDGEN_EXTRA_CLANG_ARGS")
|
||||
+ .expect("the BINDGEN_EXTRA_CLANG_ARGS environment variable must be specified and UTF-8")
|
||||
.opt_level(3)
|
||||
.debug(true)
|
||||
.compile("pgvectorsc");
|
3626
pkgs/servers/sql/postgresql/ext/pgvecto-rs/Cargo.lock
generated
Normal file
3626
pkgs/servers/sql/postgresql/ext/pgvecto-rs/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
112
pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix
Normal file
112
pkgs/servers/sql/postgresql/ext/pgvecto-rs/default.nix
Normal file
|
@ -0,0 +1,112 @@
|
|||
{ lib
|
||||
, buildPgrxExtension
|
||||
, cargo-pgrx
|
||||
, clang_16
|
||||
, fetchCrate
|
||||
, fetchFromGitHub
|
||||
, nix-update-script
|
||||
, openssl
|
||||
, pkg-config
|
||||
, postgresql
|
||||
, rustPlatform
|
||||
, stdenv
|
||||
, substituteAll
|
||||
}:
|
||||
|
||||
let
|
||||
# Upstream only works with clang 16, so we're pinning it here to
|
||||
# avoid future incompatibility.
|
||||
# See https://docs.pgvecto.rs/developers/development.html#environment, step 4
|
||||
clang = clang_16;
|
||||
rustPlatform' = rustPlatform // {
|
||||
bindgenHook = rustPlatform.bindgenHook.override { inherit clang; };
|
||||
};
|
||||
|
||||
# Upstream only works with a fixed version of cargo-pgrx for each release,
|
||||
# so we're pinning it here to avoid future incompatibility.
|
||||
# See https://docs.pgvecto.rs/developers/development.html#environment, step 6
|
||||
cargo-pgrx_0_11_2 = cargo-pgrx.overrideAttrs (old: rec {
|
||||
pname = "cargo-pgrx";
|
||||
version = "0.11.2";
|
||||
|
||||
src = fetchCrate {
|
||||
pname = "cargo-pgrx";
|
||||
inherit version;
|
||||
hash = "sha256-8NlpMDFaltTIA8G4JioYm8LaPJ2RGKH5o6sd6lBHmmM=";
|
||||
};
|
||||
|
||||
cargoDeps = old.cargoDeps.overrideAttrs (_: {
|
||||
inherit src;
|
||||
outputHash = "sha256-qTb3JV3u42EilaK2jP9oa5D09mkuHyRbGGRs9Rg4TzI=";
|
||||
});
|
||||
});
|
||||
|
||||
in
|
||||
(buildPgrxExtension.override {
|
||||
cargo-pgrx = cargo-pgrx_0_11_2;
|
||||
rustPlatform = rustPlatform';
|
||||
}) rec {
|
||||
inherit postgresql;
|
||||
|
||||
pname = "pgvecto-rs";
|
||||
version = "0.2.1";
|
||||
|
||||
buildInputs = [ openssl ];
|
||||
nativeBuildInputs = [ pkg-config ];
|
||||
|
||||
patches = [
|
||||
# Tell the `c` crate to use the flags from the rust bindgen hook
|
||||
(substituteAll {
|
||||
src = ./0001-read-clang-flags-from-environment.diff;
|
||||
clang = lib.getExe clang;
|
||||
})
|
||||
];
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "tensorchord";
|
||||
repo = "pgvecto.rs";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-kwaGHerEVh6Oxb9jQupSapm7CsKl5CoH6jCv+zbi4FE=";
|
||||
};
|
||||
|
||||
# Package has git dependencies on Cargo.lock (instead of just crate.io dependencies),
|
||||
# so cargoHash does not work, therefore we have to include Cargo.lock in nixpkgs.
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
outputHashes = {
|
||||
"openai_api_rust-0.1.8" = "sha256-os5Y8KIWXJEYEcNzzT57wFPpEXdZ2Uy9W3j5+hJhhR4=";
|
||||
"std_detect-0.1.5" = "sha256-RwWejfqyGOaeU9zWM4fbb/hiO1wMpxYPKEjLO0rtRmU=";
|
||||
};
|
||||
};
|
||||
|
||||
# Set appropriate version on vectors.control, otherwise it won't show up on PostgreSQL
|
||||
postPatch = ''
|
||||
substituteInPlace ./vectors.control --subst-var-by CARGO_VERSION ${version}
|
||||
'';
|
||||
|
||||
# Include upgrade scripts in the final package
|
||||
# https://github.com/tensorchord/pgvecto.rs/blob/v0.2.0/scripts/ci_package.sh#L6-L8
|
||||
postInstall = ''
|
||||
cp sql/upgrade/* $out/share/postgresql/extension/
|
||||
'';
|
||||
|
||||
env = {
|
||||
# Needed to get openssl-sys to use pkg-config.
|
||||
OPENSSL_NO_VENDOR = 1;
|
||||
|
||||
# Bypass rust nightly features not being available on rust stable
|
||||
RUSTC_BOOTSTRAP = 1;
|
||||
};
|
||||
|
||||
passthru.updateScript = nix-update-script { };
|
||||
|
||||
meta = with lib; {
|
||||
# The pgrx 0.11.2 dependency is broken in aarch64-linux: https://github.com/pgcentralfoundation/pgrx/issues/1429
|
||||
# It is fixed in pgrx 0.11.3, but upstream is still using pgrx 0.11.2
|
||||
broken = (stdenv.isLinux && stdenv.isAarch64) || stdenv.isDarwin;
|
||||
description = "Scalable, Low-latency and Hybrid-enabled Vector Search in Postgres";
|
||||
homepage = "https://github.com/tensorchord/pgvecto.rs";
|
||||
license = licenses.asl20;
|
||||
maintainers = with maintainers; [ diogotcorreia esclear ];
|
||||
};
|
||||
}
|
|
@ -44,6 +44,8 @@ self: super: {
|
|||
|
||||
pgsql-http = super.callPackage ./ext/pgsql-http.nix { };
|
||||
|
||||
pgvecto-rs = super.callPackage ./ext/pgvecto-rs { };
|
||||
|
||||
pgvector = super.callPackage ./ext/pgvector.nix { };
|
||||
|
||||
plpgsql_check = super.callPackage ./ext/plpgsql_check.nix { };
|
||||
|
|
Loading…
Reference in a new issue