infra/nix/hosts/loki/modules/containers/immich.nix
2026-01-05 23:09:19 +01:00

201 lines
7.1 KiB
Nix

{ config, ... }:
let
immichHost = "domain"; # TODO: put your immich domain name here
immichRoot = "/DATA/services/immich"; # TODO: Tweak these to your desired storage locations
immichPhotos = "${immichRoot}/photos";
immichAppdataRoot = "${immichRoot}/appdata";
# immichVersion = "release";
immichVersion = "amd64-noml";
# immichExternalVolume1 = "/tank/BackupData/Google Photos/someone@example.com"; # TODO: if external volumes are desired
postgresRoot = "${immichAppdataRoot}/pgsql";
postgresPassword = "passw";
postgresUser = "immich";
postgresDb = "immich";
in
{
# services.postgresql = {
# ensureDatabases = [postgresDb];
# extraPlugins = ps; with ps; ["pgvecto.rs"];
# };
virtualisation.oci-containers.containers.immich = {
image = "ghcr.io/imagegenius/immich:${immichVersion}";
# ports = ["127.0.0.1:2283:3001"];
ports = [ "127.0.0.1:2283:8080" ];
extraOptions = [
"--pull=newer"
# Force DNS resolution to only be the podman dnsname name server; by
# default podman provides a resolv.conf that includes both this server
# and the upstream system server, causing resolutions of other pod names
# to be inconsistent.
"--dns=dnsip"
];
# cmd = [ "start.sh" "immich" ];
environment = {
IMMICH_VERSION = immichVersion;
PUID = "1000";
PGID = "1000";
TZ = "Europe/Berlin";
# DB_HOSTNAME = "immich_postgres";
DB_HOSTNAME = "IP";
# DB_HOSTNAME ="localhost";
DB_USERNAME = postgresUser;
DB_DATABASE_NAME = postgresDb;
DB_PASSWORD = postgresPassword;
DB_PORT = "5482";
# DB_URL = "postgresql://localhost:5482";
# REDIS_HOSTNAME = "immich_redis";
# REDIS_HOSTNAME = "localhost";
REDIS_HOSTNAME = "REDIS";
# DOCKER_MODS = "imagegenius/mods:universal-redis"; # XXX: this didn't work.
};
volumes = [
# "${immichPhotos}:/usr/src/app/upload"
"${immichPhotos}:/photos"
# "${immichPhotos}:/libraries"
"${immichAppdataRoot}/config:/config"
"/etc/localtime:/etc/localtime:ro"
# "${immichExternalVolume1}:${immichExternalVolume1}:ro"
];
};
networking.firewall.interfaces.tailscale0.allowedTCPPorts = [
5482
6379
];
virtualisation.oci-containers.containers.immich_postgres = {
# image = "docker.io/tensorchord/pgvecto-rs:pg14-v0.1.11";
# image = "docker.io/tensorchord/pgvecto-rs:pg14-v0.2.0";
image = "docker.io/tensorchord/pgvecto-rs:pg16-v0.2.0";
# ports = ["127.0.0.1:5482:5432"];
ports = [ "5482:5432" ];
environment = {
POSTGRES_PASSWORD = postgresPassword;
POSTGRES_USER = postgresUser;
POSTGRES_DB = postgresDb;
};
volumes = [
"${postgresRoot}:/var/lib/postgresql/data"
];
};
virtualisation.oci-containers.containers.immich_redis = {
image = "redis:6.2-alpine@sha256:80cc8518800438c684a53ed829c621c94afd1087aaeb59b0d4343ed3e7bcf6c5";
# image = "docker.io/library/redis:mine";
ports = [ "6379:6379" ];
volumes = [
"${immichAppdataRoot}/redis:/data"
];
};
#services.nginx.virtualHosts."${immichHost}" = {
# extraConfig = ''
# ## Per https://immich.app/docs/administration/reverse-proxy...
# client_max_body_size 50000M;
# '';
# forceSSL = true;
# enableACME = true;
# locations."/" = {
# proxyPass = "http://127.0.0.1:2283";
# proxyWebsockets = true;
# };
#};
# The primary source for this configuration is the recommended docker-compose installation of immich from
# https://immich.app/docs/install/docker-compose, which linkes to:
# - https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
# - https://github.com/immich-app/immich/releases/latest/download/example.env
# and has been transposed into nixos configuration here. Those upstream files should probably be checked
# for serious changes if there are any upgrade problems here.
#
# After initial deployment, these in-process configurations need to be done:
# - create an admin user by accessing the site
# - login with the admin user
# - set the "Machine Learning Settings" > "URL" to http://immich_machine_learning:3003
### virtualisation.oci-containers.containers.immich_server = {
### image = "ghcr.io/immich-app/immich-server:${immichVersion}";
### ports = ["127.0.0.1:2283:3001"];
### extraOptions = [
### "--pull=newer"
### # Force DNS resolution to only be the podman dnsname name server; by default podman provides a resolv.conf
### # that includes both this server and the upstream system server, causing resolutions of other pod names
### # to be inconsistent.
### "--dns=dnsip"
### ];
### cmd = [ "start.sh" "immich" ];
### environment = {
### IMMICH_VERSION = immichVersion;
### DB_HOSTNAME = "immich_postgres";
### DB_USERNAME = postgresUser;
### DB_DATABASE_NAME = postgresDb;
### DB_PASSWORD = postgresPassword;
### REDIS_HOSTNAME = "immich_redis";
### };
### volumes = [
### "${immichPhotos}:/usr/src/app/upload"
### "/etc/localtime:/etc/localtime:ro"
### # "${immichExternalVolume1}:${immichExternalVolume1}:ro"
### ];
### };
### virtualisation.oci-containers.containers.immich_microservices = {
### image = "ghcr.io/immich-app/immich-server:${immichVersion}";
### extraOptions = [
### "--pull=newer"
### # Force DNS resolution to only be the podman dnsname name server; by default podman provides a resolv.conf
### # that includes both this server and the upstream system server, causing resolutions of other pod names
### # to be inconsistent.
### "--dns=dns"
### ];
### cmd = [ "start.sh" "microservices" ];
### environment = {
### IMMICH_VERSION = immichVersion;
### DB_HOSTNAME = "immich_postgres";
### DB_USERNAME = postgresUser;
### DB_DATABASE_NAME = postgresDb;
### DB_PASSWORD = postgresPassword;
### REDIS_HOSTNAME = "immich_redis";
### };
### volumes = [
### "${immichPhotos}:/usr/src/app/upload"
### "/etc/localtime:/etc/localtime:ro"
### # "${immichExternalVolume1}:${immichExternalVolume1}:ro"
### ];
### };
### virtualisation.oci-containers.containers.immich_machine_learning = {
### image = "ghcr.io/immich-app/immich-machine-learning:${immichVersion}";
### extraOptions = [
### "--pull=newer"
### "--dns=dnsip"
### ];
### environment = {
### IMMICH_VERSION = immichVersion;
### };
### volumes = [
### "${immichAppdataRoot}/model-cache:/cache"
### ];
### };
### virtualisation.oci-containers.containers.immich_redis = {
### image = "redis:6.2-alpine@sha256:80cc8518800438c684a53ed829c621c94afd1087aaeb59b0d4343ed3e7bcf6c5";
### };
### virtualisation.oci-containers.containers.immich_postgres = {
### image = "tensorchord/pgvecto-rs:pg14-v0.1.11";
### environment = {
### POSTGRES_PASSWORD = postgresPassword;
### POSTGRES_USER = postgresUser;
### POSTGRES_DB = postgresDb;
### };
### volumes = [
### "${postgresRoot}:/var/lib/postgresql/data"
### ];
### };
}