{ config, lib, ... }:
let
  settings = import ../settings.nix;
  immichPort = 2283;
  dataDir = "/media/nas/main/photos";
  dbPassword = config.sops.secrets."jallen-nas/immich/db-password".path;
in
{
  # Enable immich service
  services.immich = {
    enable = true;
    port = immichPort;
    openFirewall = true;
    secretsFile = dbPassword;
    mediaLocation = dataDir;

    environment = {
      IMMICH_HOST = lib.mkForce "0.0.0.0";
      IMMICH_TRUSTED_PROXIES = settings.hostAddress;
      TZ = "America/Chicago";
    };

    machine-learning = {
      enable = true;
    };
  };
}
