mirror of
https://github.com/tuxdotrs/nix-config.git
synced 2026-09-20 00:59:04 +05:30
refactor(services): standardize host and proxy options
This commit is contained in:
@@ -15,6 +15,12 @@
|
||||
options.tnix.services.uptime-kuma = {
|
||||
enable = mkEnableOption "Uptime Kuma";
|
||||
|
||||
host = mkOption {
|
||||
type = types.str;
|
||||
default = "127.0.0.1";
|
||||
description = "Host on which Uptime Kuma listens";
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
type = types.port;
|
||||
default = 1111;
|
||||
@@ -24,25 +30,39 @@
|
||||
domain = mkOption {
|
||||
type = types.str;
|
||||
default = "";
|
||||
description = "Domain on which nginx serves Uptime Kuma (disabled when empty)";
|
||||
description = "Domain on which Uptime Kuma is available";
|
||||
};
|
||||
|
||||
configureNginx = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = "Whether to configure Nginx as a reverse proxy for Uptime Kuma";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
assertions = [
|
||||
{
|
||||
assertion = cfg.domain != "";
|
||||
message = "tnix.services.uptime-kuma.domain must be set when tnix.services.uptime-kuma.enable is true.";
|
||||
}
|
||||
];
|
||||
|
||||
services = {
|
||||
uptime-kuma = {
|
||||
enable = true;
|
||||
settings = {
|
||||
HOST = "127.0.0.1";
|
||||
HOST = cfg.host;
|
||||
PORT = port;
|
||||
};
|
||||
};
|
||||
|
||||
nginx.virtualHosts.${cfg.domain} = mkIf (cfg.domain != "") {
|
||||
nginx.virtualHosts.${cfg.domain} = mkIf cfg.configureNginx {
|
||||
forceSSL = acmeHost != "";
|
||||
useACMEHost = mkIf (acmeHost != "") acmeHost;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${port}";
|
||||
proxyPass = "http://${cfg.host}:${port}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user