48 lines
1.3 KiB
Nix
48 lines
1.3 KiB
Nix
{ lib, config, ... }:
|
|
let
|
|
mkOptions = name: subdomain: port: {
|
|
enable = lib.mkEnableOption "enable";
|
|
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;
|
|
};
|
|
host = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "${subdomain}.${config.my.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;
|
|
};
|
|
};
|
|
in
|
|
{
|
|
inherit mkOptions;
|
|
}
|