Change:
<ins> { lib , buildPgrxExtension , cargo-pgrx , clang_16 , fetchCrate , fetchFromGitHub , nix-update-script , nixosTests , 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 { }; tests = { pgvecto-rs = nixosTests.pgvecto-rs; }; }; 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 ]; }; } </ins>

Discussion:
Project description Scalable Vector database plugin for Postgres, written in Rust, specifically designed for LLM Immich 1.91 requires this extension for it's PostreSQL database. Metadata homepage URL: source URL: license: asl20 platforms: unix, linux, darwin, ... Add a :+1: [reaction] to [issues you find important]. [reaction]: [issues you find important]:
While it doesn't build from source, I've come across this derivation of which packages the appropriate binary release:
thanks for that link! That should get me going for now until a native package can be to nixpkgs.
Did anyone get this working? I'm quite new to Nix and haven't got a clue where to start with installing a custom package.
Hi Yes, I've got it working , and presumably has as well (whose dotfiles repo I linked to). Typically to include a custom nix package in your config, you merge it into the upstream nixpkgs that your config is already pulling from by using . I do this in my config - my file is just a big function with arguments (aka an overlay). I then (so is now an overlay) and then pass that in the list when instantiating nixpkgs. ( is ). does things a bit differently. They have which is a function with arguments , which returns a derivation (created via ). This then has before that overlay is finally . So in short, you have a package derivation (either the output of or (or other functions)). You need to get it into an overlay function, then pass that overlay function when creating your instance of nixpkgs. I appreciate this is not simple :) Ideally someone can PR this to nixpkgs to make this easier for everyone (though we should really get building it from source working first). I learned myself by piecing together bits of other user's configs. If you want more fine-grained help, check out .
If no one else picks this up in the next few days I might give it a shot if I have time, but as I said in my comment this would need to be packaged as well. Thanks for the amazing explanation above!
is already packaged. One problem that I ran into is that cargo-pgrx is built with rust-stable while seems to need to be built with rust-nightly.

you can see how I got working in my .
Hey! I've just managed to package version (and it took me way too long)! Unfortunately, I was getting a weird linker error on , so I went straight for the beta instead. I'll be keeping an eye for when it releases as a stable version (i.e., ). I have to say that I have not tested it in Immich yet, but it builds and enables correctly on PostgreSQL. With that said, I'll be submitting a draft PR shortly, so that I can start getting reviews. Thank you for telling me about , that helped a lot. I got around the rust nightly limitation by using the env variable and a few patches.
Do you have a link to your repo? I had tried with using the previous methods and it broke my immich. I had to revert to an older database backup to recover and installing (the one that is used by the docker-compose file) and then it worked.
That's not good news :sob: I do have my repo at , but I have not pushed yet. This issue seems to indicate that this will be temporary and they plan to upgrade to a newer version when it's more stable:
Hey! I've (almost) finished the PR to add 0.2.0 (which will be the targeted version in the next version of Immich, see ). I have left some comments about stuff I'm not certain about, so if you have the knowledge to do so, I'd appreciate if you could go there and leave a review! Thank you!