depot/hosts/VEGAS/services/uptime-kuma/default.nix

79 lines
1.7 KiB
Nix
Raw Normal View History

2023-02-24 16:16:15 +02:00
{ config, depot, lib, tools, ... }:
2022-04-27 23:08:49 +03:00
let
inherit (tools.meta) domain;
2022-06-18 03:44:51 +03:00
link = config.links.uptime-kuma;
2022-04-27 23:08:49 +03:00
dataDir = "/srv/storage/private/uptime-kuma";
in
{
2022-06-18 03:44:51 +03:00
links.uptime-kuma.protocol = "http";
2022-04-27 23:08:49 +03:00
users.users.uptime-kuma = {
isSystemUser = true;
home = "${dataDir}/.home";
group = "uptime-kuma";
};
users.groups.uptime-kuma = {};
systemd.tmpfiles.rules = [
"d '${dataDir}' 0700 uptime-kuma uptime-kuma - -"
];
systemd.services.uptime-kuma = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
User = "uptime-kuma";
Group = "uptime-kuma";
ProtectSystem = "strict";
ReadWritePaths = [ dataDir ];
ProtectHome = "tmpfs";
RestrictAddressFamilies = [
"AF_INET"
"AF_INET6"
"AF_NETLINK"
];
NoNewPrivileges = true;
PrivateTmp = true;
PrivateDevices = true;
PrivateUsers = true;
LockPersonality = true;
SystemCallArchitectures = [ "native" ];
ProtectClock = true;
ProtectControlGroups = true;
ProtectHostname = true;
ProtectKernelLogs = true;
ProtectKernelModules = true;
ProtectKernelTunables = true;
2023-02-24 16:16:15 +02:00
ExecStart = depot.packages.uptime-kuma + /bin/uptime-kuma;
2022-04-27 23:08:49 +03:00
};
environment = {
NODE_ENV = "production";
DATA_DIR = dataDir;
2022-06-18 03:44:51 +03:00
UPTIME_KUMA_HOST = link.ipv4;
UPTIME_KUMA_PORT = link.portStr;
2022-04-27 23:08:49 +03:00
UPTIME_KUMA_HIDE_LOG = lib.concatStringsSep "," [
"debug_monitor"
"info_monitor"
];
};
};
2022-06-18 03:44:51 +03:00
services.nginx.virtualHosts."status.${domain}" = lib.recursiveUpdate (tools.nginx.vhosts.proxy link.url) {
2022-04-27 23:08:49 +03:00
locations = {
"/".proxyWebsockets = true;
"=/".return = "302 /status/${builtins.replaceStrings ["."] ["-"] domain}";
};
};
}