{ config, containerCfg, pkgs, lib, builder, name,... }: let version = "v2"; serverCfg = config.syscfg.server; in { sops = true; db = true; paths = [{ path = "${serverCfg.configPath}/immich/cache"; mode = "0750"; }{ path = "${serverCfg.dataPath}/immich/"; owner = "1000:1000"; mode = "0755"; }]; containers = { server = builder.mkContainer { subdomain = containerCfg.subdomain; image = "ghcr.io/immich-app/immich-server:${version}"; port = 2283; secret = name; extraEnv = { IMMICH_MACHINE_LEARNING_URL = "http://immich-ml:3003"; REDIS_HOSTNAME = builder.host; IMMICH_IGNORE_MOUNT_CHECK_ERRORS=true; }; overrides = { volumes = [ "${serverCfg.dataPath}/immich:/data" ]; }; }; ml = builder.mkContainer { image = "ghcr.io/immich-app/immich-machine-learning:${version}"; port = 3003; overrides = { volumes = [ "${serverCfg.configPath}/immich/cache:/cache" ]; }; }; }; setup = { trigger = "server"; script = pkgs.writeShellScript "setup" '' PSQL="${pkgs.postgresql}/bin/psql -U postgres" $PSQL -d "immich_db" -tAc "CREATE EXTENSION IF NOT EXISTS vchord CASCADE;" $PSQL -d "immich_db" -tAc "CREATE EXTENSION IF NOT EXISTS earthdistance CASCADE;" ''; }; }