{ pkgs, lib, config, ... }: {
  options.mods.server.photoprism = {
    enable = lib.mkEnableOption {
      default = false;
      description = "enables photoprism server";
    };
  };

  config = lib.mkIf config.mods.server.photoprism.enable {
    services.photoprism = {
      enable = true;
      port = 2342;
      originalsPath = "/var/lib/private/photoprism/originals";
      address = "0.0.0.0";
      settings = {
        PHOTOPRISM_ADMIN_USER = "admin";
        PHOTOPRISM_ADMIN_PASSWORD = "CarrotSec";
        PHOTOPRISM_DEFAULT_LOCALE = "en";
        PHOTOPRISM_DATABASE_DRIVER = "mysql";
        PHOTOPRISM_DATABASE_NAME = "photoprism";
        PHOTOPRISM_DATABASE_SERVER = "/run/mysqld/mysqld.sock";
        PHOTOPRISM_DATABASE_USER = "photoprism";
        PHOTOPRISM_SITE_URL = "http://93.95.230.11:2342";
        PHOTOPRISM_SITE_TITLE = "Giceland Potos";
      };
    };

    networking.firewall.allowedTCPPorts = [ 2342 ];

    # MySQL
    services.mysql = {
      enable = true;
      dataDir = "/data/mysql";
      package = pkgs.mariadb;
      ensureDatabases = [ "photoprism" ];
      ensureUsers = [{
        name = "photoprism";
        ensurePermissions = { "photoprism.*" = "ALL PRIVILEGES"; };
      }];
    };
  };
}
