{ pkgs, lib, config, ... }:
let
  cfg = config.mods.server;
  port = cfg.nginx.ports.photos;
in with lib; {
  options.mods.server = {
    movies = {
      enable = mkEnableOption {
        default = false;
        description = "enables jellyfin server";
      };
    };

    photos = {
      enable = mkEnableOption {
        default = false;
        description = "enables immich server";
      };
    };
  };

  config = {
    services.jellyfin = mkIf cfg.movies.enable {
      enable = true;
      openFirewall = true;
      user = "${config.mods.user.name}";
    };

    services.immich = mkIf cfg.photos.enable {
      enable = true;
      openFirewall = true;
      host = "0.0.0.0";
      port = port;
    };
    users.users.immich =
      mkIf cfg.photos.enable { extraGroups = [ "video" "render" ]; };
  };
}
