Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request: pgvecto.rs #274509

Closed
jcollie opened this issue Dec 15, 2023 · 10 comments · Fixed by #281192
Closed

Package request: pgvecto.rs #274509

jcollie opened this issue Dec 15, 2023 · 10 comments · Fixed by #281192
Labels
0.kind: packaging request Request for a new package to be added

Comments

@jcollie
Copy link

jcollie commented Dec 15, 2023

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


Add a 👍 reaction to issues you find important.

@jcollie jcollie added the 0.kind: packaging request Request for a new package to be added label Dec 15, 2023
@anoadragon453
Copy link
Member

While it doesn't build from source, I've come across this derivation of pgvecto.rs which packages the appropriate binary release: https://github.com/diogotcorreia/dotfiles/blob/7676201683a3785ef17eff9f4ad3295375c670bd/packages/pgvecto-rs.nix

@jcollie
Copy link
Author

jcollie commented Dec 16, 2023

@anoadragon453 thanks for that link! That should get me going for now until a native package can be added to nixpkgs.

@alexmoras
Copy link

Did anyone get this working? I'm quite new to Nix and haven't got a clue where to start with installing a custom .nix package.

@anoadragon453
Copy link
Member

anoadragon453 commented Dec 17, 2023

Hi @alexmoras. Yes, I've got it working in my config, and presumably @diogotcorreia 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 overlays. I do this in my config - my pkgs/default.nix file is just a big function with self: super: arguments (aka an overlay). I then import that file (so localpkgs is now an overlay) and then pass that in the overlays list when instantiating nixpkgs. (lib.mkPkgs is yet another custom function).

@diogotcorreia does things a bit differently. They have a package definition which is a function with arguments { lib, stdenv, fetchurl, dpkg, postgresql }:, which returns a derivation (created via stdenv.mkDerivation).

This then has callPackage called on it, before wrapping it into an overlay before that overlay is finally used when creating a nixpkgs intstance.

So in short, you have a package derivation (either the output of stdenv.mkDerivation or nixpkgs.callPackage (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 the NixOS matrix chatroom.

@diogotcorreia
Copy link
Member

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 #244803 (comment) this would need cargo-pgrx to be packaged as well.

Thanks @anoadragon453 for the amazing explanation above!

@jcollie
Copy link
Author

jcollie commented Dec 17, 2023

@diogotcorreia cargo-pgrx is already packaged. One problem that I ran into is that cargo-pgrx is built with rust-stable while pgvecto.rs seems to need to be built with rust-nightly.

@alexmoras you can see how I got pgvecto.rs working in my flake.

@diogotcorreia
Copy link
Member

Hey!

I've just managed to package pgvecto.rs version 0.1.14-beta (and it took me way too long)! Unfortunately, I was getting a weird linker error on 0.1.13, so I went straight for the beta instead.
I'll be keeping an eye for when it releases as a stable version (i.e., 0.1.14).
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 @jcollie for telling me about buildPgrxExtension, that helped a lot. I got around the rust nightly limitation by using the RUSTC_BOOTSTRAP env variable and a few patches.

@EricTheMagician
Copy link
Contributor

@diogotcorreia Do you have a link to your repo?

I had tried with 0.1.13 using the previous methods and it broke my immich. I had to revert to an older database backup to recover and installing 0.1.11 (the one that is used by the docker-compose file) and then it worked.

@diogotcorreia
Copy link
Member

@EricTheMagician That's not good news 😭
I do have my repo at https://github.com/diogotcorreia/dotfiles, 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: immich-app/immich#5911

@diogotcorreia
Copy link
Member

Hey!
I've (almost) finished the PR to add pgvecto.rs 0.2.0 (which will be the targeted version in the next version of Immich, see #281192 (comment)).

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! #281192

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: packaging request Request for a new package to be added
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants