{ lib, config, ... }: let mkOptions = name: subdomain: port: { enable = lib.mkEnableOption "this server service"; enableCron = lib.mkEnableOption "enable cronjob"; enableProxy = lib.mkEnableOption "enable reverse proxy"; port = lib.mkOption { type = lib.types.int; default = port; }; name = lib.mkOption { type = lib.types.str; default = name; }; domain = lib.mkOption { type = lib.types.str; default = config.my.domain; }; host = lib.mkOption { type = lib.types.str; default = "${subdomain}.${config.my.servers.${name}.domain}"; }; hostName = lib.mkOption { type = lib.types.str; default = config.networking.hostName; }; url = lib.mkOption { type = lib.types.str; default = "https://${config.my.servers.${name}.host}"; }; ip = lib.mkOption { type = lib.types.str; default = if config.my.servers."${name}".isLocal then config.my.localhost else config.my.ips."${config.my.servers.${name}.hostName}"; }; local = lib.mkOption { type = lib.types.str; default = "http://${config.my.servers.${name}.ip}:${toString port}"; }; isLocal = lib.mkOption { type = lib.types.bool; default = "${config.my.servers.${name}.hostName}" == config.my.mainServer; }; enableSocket = lib.mkOption { type = lib.types.bool; default = false; }; certPath = lib.mkOption { type = lib.types.nullOr lib.types.path; default = null; }; }; in { inherit mkOptions; mkServerOptions = mkOptions; }