Skip to content

Commit

Permalink
chore(hera): update immich to v1.91.0
Browse files Browse the repository at this point in the history
  • Loading branch information
diogotcorreia committed Dec 15, 2023
1 parent bbfe6be commit 7676201
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 31 deletions.
43 changes: 12 additions & 31 deletions hosts/hera/immich.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ let
serverAndMicroservices = {
imageName = "ghcr.io/immich-app/immich-server";
imageDigest =
"sha256:71b1e4f64e08aa26df1cb02687c58214ebded1fdc10eef21fedf08138e9771dd"; # v1.90.1
sha256 = "sha256-ypHkVpFE4NgG+7FFKyvS5ppnc8bO3F5pX+hs0DROvEM=";
"sha256:293673607cdc62be83d4982db491544959070982bdd7bab3181f8bbed485e619"; # v1.91.0
sha256 = "sha256-lbgZ82TJzNnsjx2VHaN/KEOUK55wKeTjA0bkubnaUt8=";
};
machineLearning = {
imageName = "ghcr.io/immich-app/immich-machine-learning";
imageDigest =
"sha256:04d2f5dea4b623c7442f84195927eb81d9c273882fe0cc360c56116f1dd7a948"; # v1.90.1
sha256 = "sha256-9I5Pjrt0L6ccRpGjO0L6JSFIc/qZhKq1+tCk8OkEUCQ=";
"sha256:4d5614c2f372acdc779a398f9c27e10ae35f3777fd34dd3f63cf88012644438f"; # v1.91.0
sha256 = "sha256-df00J92Uils7uaoqMkxt97ALgWIjXwY+fxku0OvIiHY=";
};
};
dbUsername = user;
Expand All @@ -41,20 +41,13 @@ let
domain = "photos.diogotc.com";
immichExternalPort = 8084;

typesenseHost = "immich_typesense";
typesenseApiKey =
"abcxyz123"; # doesn't matter since it's not accessible from the outside

environment = {
DB_URL = "socket://${dbUsername}:@/run/postgresql?db=${dbUsername}";

REDIS_SOCKET = config.services.redis.servers.${redisName}.unixSocket;

UPLOAD_LOCATION = photosLocation;

TYPESENSE_HOST = typesenseHost;
TYPESENSE_API_KEY = typesenseApiKey;

IMMICH_WEB_URL = immichWebUrl;
IMMICH_SERVER_URL = immichServerUrl;
IMMICH_MACHINE_LEARNING_URL = immichMachineLearningUrl;
Expand Down Expand Up @@ -91,6 +84,14 @@ in {
ensureDBOwnership = true;
}];
ensureDatabases = [ dbUsername ];

extraPlugins = [
(pkgs.my.pgvecto-rs.override rec {
postgresql = config.services.postgresql.package;
stdenv = postgresql.stdenv;
})
];
settings = { shared_preload_libraries = "vectors.so"; };
};

services.redis.servers.${redisName} = {
Expand Down Expand Up @@ -122,8 +123,6 @@ in {
PGID = toString gid;
};

dependsOn = [ typesenseHost ];

ports = [ "${toString immichExternalPort}:3001" ];

autoStart = true;
Expand Down Expand Up @@ -151,8 +150,6 @@ in {
REVERSE_GEOCODING_DUMP_DIRECTORY = "/tmp/reverse-geocoding-dump";
};

dependsOn = [ typesenseHost ];

autoStart = true;
};

Expand All @@ -167,22 +164,6 @@ in {

autoStart = true;
};

${typesenseHost} = {
image = "typesense/typesense:0.24.0";
extraOptions = [ "--network=immich-bridge" ];

environment = {
TYPESENSE_API_KEY = typesenseApiKey;
TYPESENSE_DATA_DIR = "/data";
};

log-driver = "none";

volumes = [ "immich-tsdata:/data" ];

autoStart = true;
};
};

systemd.services.init-immich-network = {
Expand Down
46 changes: 46 additions & 0 deletions packages/pgvecto-rs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# packages/pgvecto-rs.nix
#
# Author: Diogo Correia <[email protected]>
# URL: https://github.com/diogotcorreia/dotfiles
#
# A PostgreSQL extension needed for Immich.
# This builds from the pre-compiled binary instead of from source.

{ lib, stdenv, fetchurl, dpkg, postgresql }:

let
versionHashes = {
"14" = "sha256-8YRC1Cd9i0BGUJwLmUoPVshdD4nN66VV3p48ziy3ZbA=";
};
major = lib.versions.major postgresql.version;
in stdenv.mkDerivation rec {
pname = "pgvecto-rs";
version = "0.1.11";

buildInputs = [ dpkg ];

src = fetchurl {
url =
"https://github.com/tensorchord/pgvecto.rs/releases/download/v${version}/vectors-pg${major}-v${version}-x86_64-unknown-linux-gnu.deb";
hash = versionHashes."${major}";
};

dontUnpack = true;
dontBuild = true;
dontStrip = true;

installPhase = ''
mkdir -p $out
dpkg -x $src $out
install -D -t $out/lib $out/usr/lib/postgresql/${major}/lib/*.so
install -D -t $out/share/postgresql/extension $out/usr/share/postgresql/${major}/extension/*.sql
install -D -t $out/share/postgresql/extension $out/usr/share/postgresql/${major}/extension/*.control
rm -rf $out/usr
'';

meta = with lib; {
description =
"pgvecto.rs extension for PostgreSQL: Scalable Vector database plugin for Postgres, written in Rust, specifically designed for LLM";
homepage = "https://github.com/tensorchord/pgvecto.rs";
};
}

0 comments on commit 7676201

Please sign in to comment.