{ inputs, ... }: { flake.modules.nixos.immich = { lib, pkgs, config, ... }: { imports = with inputs.self.modules.nixos; [ podman ]; age.secrets = { immich.file = ../../../secrets/immich.age; immichdb.file = ../../../secrets/immichdb.age; }; virtualisation.oci-containers.containers = { "immich-machine-learning" = { image = "ghcr.io/immich-app/immich-machine-learning:release"; volumes = [ "model-cache:/cache" ]; log-driver = "journald"; extraOptions = [ "--pod=immich" ]; environmentFiles = [ "${config.age.secrets.immich.path}" ]; }; "redis" = { image = "docker.io/valkey/valkey:9@sha256:3b55fbaa0cd93cf0d9d961f405e4dfcc70efe325e2d84da207a0a8e6d8fde4f9"; log-driver = "journald"; extraOptions = [ "--pod=immich" ]; }; "immich_database" = { image = "ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23"; environmentFiles = [ "${config.age.secrets.immichdb.path}" ]; volumes = [ "/DockerData/configs/immich/db:/var/lib/postgresql/data" ]; extraOptions = [ "--pod=immich" ]; log-driver = "journald"; }; "immich_server" = { image = "ghcr.io/immich-app/immich-server:release"; volumes = [ "/DockerData/configs/immich/library:/usr/src/app/upload" "/etc/localtime:/etc/localtime:ro" ]; environment = { DB_HOSTNAME = "localhost"; REDIS_HOSTNAME = "localhost"; }; log-driver = "journald"; extraOptions = [ "--pod=immich" ]; environmentFiles = [ "${config.age.secrets.immich.path}" ]; dependsOn = [ "redis" "immich_database" ]; }; }; systemd = { services = { "podman-immich-machine-learning" = { serviceConfig = { Restart = lib.mkOverride 90 "always"; }; partOf = [ "podman-compose-immich-root.target" ]; wantedBy = [ "podman-compose-immich-root.target" ]; after = [ "podman-pod-immich.service" ]; wants = [ "podman-pod-immich.service" ]; }; "podman-redis" = { serviceConfig = { Restart = lib.mkOverride 90 "always"; }; partOf = [ "podman-compose-immich-root.target" ]; wantedBy = [ "podman-compose-immich-root.target" ]; after = [ "podman-pod-immich.service" ]; wants = [ "podman-pod-immich.service" ]; }; "podman-immich_database" = { serviceConfig = { Restart = lib.mkOverride 90 "always"; }; partOf = [ "podman-compose-immich-root.target" ]; wantedBy = [ "podman-compose-immich-root.target" ]; after = [ "podman-pod-immich.service" ]; wants = [ "podman-pod-immich.service" ]; }; "podman-immich_server" = { serviceConfig = { Restart = lib.mkOverride 90 "always"; }; partOf = [ "podman-compose-immich-root.target" ]; wantedBy = [ "podman-compose-immich-root.target" ]; after = [ "podman-pod-immich.service" ]; wants = [ "podman-pod-immich.service" ]; }; "podman-pod-immich" = { path = [ pkgs.podman ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; ExecStop = "podman pod rm -f immich"; }; #Immich pod with port 2283=server script = '' podman pod inspect immich || podman pod create --name immich -p 2283:2283 ''; partOf = [ "podman-compose-immich-root.target" ]; wantedBy = [ "podman-compose-immich-root.target" ]; }; }; targets = { "podman-compose-immich-root" = { wantedBy = [ "multi-user.target" ]; }; }; }; }; }