mirror of
https://github.com/tuxdotrs/nix-config.git
synced 2026-09-20 00:59:04 +05:30
52 lines
1.2 KiB
Nix
52 lines
1.2 KiB
Nix
{
|
|
flake.modules.nixos.services =
|
|
{
|
|
config,
|
|
lib,
|
|
...
|
|
}:
|
|
with lib;
|
|
let
|
|
cfg = config.tnix.services.uptime-kuma;
|
|
port = toString cfg.port;
|
|
acmeHost = config.tnix.services.nginx.domain;
|
|
in
|
|
{
|
|
options.tnix.services.uptime-kuma = {
|
|
enable = mkEnableOption "Uptime Kuma";
|
|
|
|
port = mkOption {
|
|
type = types.port;
|
|
default = 1111;
|
|
description = "Port on which Uptime Kuma listens";
|
|
};
|
|
|
|
domain = mkOption {
|
|
type = types.str;
|
|
default = "";
|
|
description = "Domain on which nginx serves Uptime Kuma (disabled when empty)";
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable {
|
|
services = {
|
|
uptime-kuma = {
|
|
enable = true;
|
|
settings = {
|
|
HOST = "127.0.0.1";
|
|
PORT = port;
|
|
};
|
|
};
|
|
|
|
nginx.virtualHosts.${cfg.domain} = mkIf (cfg.domain != "") {
|
|
forceSSL = acmeHost != "";
|
|
useACMEHost = mkIf (acmeHost != "") acmeHost;
|
|
locations."/" = {
|
|
proxyPass = "http://127.0.0.1:${port}";
|
|
};
|
|
};
|
|
};
|
|
};
|
|
};
|
|
}
|