nixos/immich: add enableVectorChord option

This enables VectorChord in the database (currently) alongside
pgvecto.rs. Note that VectorChord requires pgvector, which is enabled as
well by this option.

Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>

Changed files
+32 -9
nixos
doc
manual
release-notes
modules
services
web-apps
+2
nixos/doc/manual/release-notes/rl-2511.section.md
···
- `services.ntpd-rs` now performs configuration validation.
+
- Immich now has support for [VectorChord](https://github.com/tensorchord/VectorChord) when using the PostgreSQL configuration provided by `services.immich.database.enable`, which replaces `pgvecto-rs`. VectorChord support can be toggled with the option `services.immich.database.enableVectorChord`.
+
- `services.postsrsd` now automatically integrates with the local Postfix instance, when enabled. This behavior can disabled using the [services.postsrsd.configurePostfix](#opt-services.postsrsd.configurePostfix) option.
- `services.pfix-srsd` now automatically integrates with the local Postfix instance, when enabled. This behavior can disabled using the [services.pfix-srsd.configurePostfix](#opt-services.pfix-srsd.configurePostfix) option.
+30 -9
nixos/modules/services/web-apps/immich.nix
···
// {
default = true;
};
+
enableVectorChord =
+
mkEnableOption "the new VectorChord extension for full-text search in Postgres"
+
// {
+
default = true;
+
};
createDB = mkEnableOption "the automatic creation of the database for immich." // {
default = true;
};
···
ensureClauses.login = true;
}
];
-
extensions = ps: with ps; [ pgvecto-rs ];
+
extensions =
+
ps:
+
[ ps.pgvecto-rs ]
+
++ lib.optionals cfg.database.enableVectorChord [
+
ps.vectors
+
ps.vectorchord
+
];
settings = {
-
shared_preload_libraries = [ "vectors.so" ];
+
shared_preload_libraries = [
+
"vectors.so"
+
]
+
++ lib.optionals cfg.database.enableVectorChord [ "vchord.so" ];
search_path = "\"$user\", public, vectors";
};
};
systemd.services.postgresql-setup.serviceConfig.ExecStartPost =
let
+
extensions = [
+
"unaccent"
+
"uuid-ossp"
+
"vectors"
+
"cube"
+
"earthdistance"
+
"pg_trgm"
+
]
+
++ lib.optionals cfg.database.enableVectorChord [
+
"vector"
+
"vchord"
+
];
sqlFile = pkgs.writeText "immich-pgvectors-setup.sql" ''
-
CREATE EXTENSION IF NOT EXISTS unaccent;
-
CREATE EXTENSION IF NOT EXISTS "uuid-ossp";
-
CREATE EXTENSION IF NOT EXISTS vectors;
-
CREATE EXTENSION IF NOT EXISTS cube;
-
CREATE EXTENSION IF NOT EXISTS earthdistance;
-
CREATE EXTENSION IF NOT EXISTS pg_trgm;
+
${lib.concatMapStringsSep "\n" (ext: "CREATE EXTENSION IF NOT EXISTS \"${ext}\";") extensions}
ALTER SCHEMA public OWNER TO ${cfg.database.user};
ALTER SCHEMA vectors OWNER TO ${cfg.database.user};
GRANT SELECT ON TABLE pg_vector_index_stat TO ${cfg.database.user};
-
ALTER EXTENSION vectors UPDATE;
+
${lib.concatMapStringsSep "\n" (ext: "ALTER EXTENSION \"${ext}\" UPDATE;") extensions}
'';
in
[