nixos/uptime-kuma: init module

Changed files
+106
nixos
doc
manual
from_md
release-notes
release-notes
modules
services
monitoring
tests
+7
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
···
<link xlink:href="options.html#opt-services.listmonk.enable">services.listmonk</link>.
</para>
</listitem>
</itemizedlist>
</section>
<section xml:id="sec-release-22.11-incompatibilities">
···
<link xlink:href="options.html#opt-services.listmonk.enable">services.listmonk</link>.
</para>
</listitem>
+
<listitem>
+
<para>
+
<link xlink:href="https://uptime.kuma.pet/">Uptime
+
Kuma</link>, a fancy self-hosted monitoring tool. Available as
+
<link linkend="opt-services.uptime-kuma.enable">services.uptime-kuma</link>.
+
</para>
+
</listitem>
</itemizedlist>
</section>
<section xml:id="sec-release-22.11-incompatibilities">
+2
nixos/doc/manual/release-notes/rl-2211.section.md
···
- [Listmonk](https://listmonk.app), a self-hosted newsletter manager. Enable using [services.listmonk](options.html#opt-services.listmonk.enable).
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
## Backward Incompatibilities {#sec-release-22.11-incompatibilities}
···
- [Listmonk](https://listmonk.app), a self-hosted newsletter manager. Enable using [services.listmonk](options.html#opt-services.listmonk.enable).
+
- [Uptime Kuma](https://uptime.kuma.pet/), a fancy self-hosted monitoring tool. Available as [services.uptime-kuma](#opt-services.uptime-kuma.enable).
+
<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
## Backward Incompatibilities {#sec-release-22.11-incompatibilities}
+1
nixos/modules/module-list.nix
···
./services/monitoring/ups.nix
./services/monitoring/uptime.nix
./services/monitoring/vmagent.nix
./services/monitoring/vnstat.nix
./services/monitoring/zabbix-agent.nix
./services/monitoring/zabbix-proxy.nix
···
./services/monitoring/ups.nix
./services/monitoring/uptime.nix
./services/monitoring/vmagent.nix
+
./services/monitoring/uptime-kuma.nix
./services/monitoring/vnstat.nix
./services/monitoring/zabbix-agent.nix
./services/monitoring/zabbix-proxy.nix
+76
nixos/modules/services/monitoring/uptime-kuma.nix
···
···
+
{ config, pkgs, lib, ... }:
+
+
with lib;
+
+
let
+
cfg = config.services.uptime-kuma;
+
in
+
{
+
+
options = {
+
services.uptime-kuma = {
+
enable = mkEnableOption (mdDoc "Uptime Kuma, this assumes a reverse proxy to be set.");
+
+
package = mkOption {
+
type = types.package;
+
example = literalExpression "pkgs.uptime-kuma";
+
default = pkgs.uptime-kuma;
+
defaultText = "pkgs.uptime-kuma";
+
description = lib.mdDoc "Uptime Kuma package to use.";
+
};
+
+
settings = lib.mkOption {
+
type =
+
lib.types.submodule { freeformType = with lib.types; attrsOf str; };
+
default = { };
+
example = {
+
PORT = "4000";
+
NODE_EXTRA_CA_CERTS = "/etc/ssl/certs/ca-certificates.crt";
+
};
+
description = lib.mdDoc ''
+
Additional configuration for Uptime Kuma, see
+
<https://github.com/louislam/uptime-kuma/wiki/Environment-Variables">
+
for supported values.
+
'';
+
};
+
};
+
};
+
+
config = mkIf cfg.enable {
+
+
services.uptime-kuma.settings = {
+
DATA_DIR = "/var/lib/uptime-kuma/";
+
NODE_ENV = mkDefault "production";
+
};
+
+
systemd.services.uptime-kuma = {
+
description = "Uptime Kuma";
+
after = [ "network.target" ];
+
wantedBy = [ "multi-user.target" ];
+
environment = cfg.settings;
+
serviceConfig = {
+
Type = "simple";
+
StateDirectory = "uptime-kuma";
+
DynamicUser = true;
+
ExecStart = "${cfg.package}/bin/uptime-kuma-server";
+
Restart = "on-failure";
+
ProtectHome = true;
+
ProtectSystem = "strict";
+
PrivateTmp = true;
+
PrivateDevices = true;
+
ProtectHostname = true;
+
ProtectClock = true;
+
ProtectKernelTunables = true;
+
ProtectKernelModules = true;
+
ProtectKernelLogs = true;
+
ProtectControlGroups = true;
+
NoNewPrivileges = true;
+
RestrictRealtime = true;
+
RestrictSUIDSGID = true;
+
RemoveIPC = true;
+
PrivateMounts = true;
+
};
+
};
+
};
+
}
+
+1
nixos/tests/all-tests.nix
···
unit-php = handleTest ./web-servers/unit-php.nix {};
upnp = handleTest ./upnp.nix {};
uptermd = handleTest ./uptermd.nix {};
usbguard = handleTest ./usbguard.nix {};
user-activation-scripts = handleTest ./user-activation-scripts.nix {};
user-home-mode = handleTest ./user-home-mode.nix {};
···
unit-php = handleTest ./web-servers/unit-php.nix {};
upnp = handleTest ./upnp.nix {};
uptermd = handleTest ./uptermd.nix {};
+
uptime-kuma = handleTest ./uptime-kuma.nix {};
usbguard = handleTest ./usbguard.nix {};
user-activation-scripts = handleTest ./user-activation-scripts.nix {};
user-home-mode = handleTest ./user-home-mode.nix {};
+19
nixos/tests/uptime-kuma.nix
···
···
+
import ./make-test-python.nix ({ lib, ... }:
+
+
with lib;
+
+
{
+
name = "uptime-kuma";
+
meta.maintainers = with maintainers; [ julienmalka ];
+
+
nodes.machine =
+
{ pkgs, ... }:
+
{ services.uptime-kuma.enable = true; };
+
+
testScript = ''
+
machine.start()
+
machine.wait_for_unit("uptime-kuma.service")
+
machine.wait_for_open_port(3001)
+
machine.succeed("curl --fail http://localhost:3001/")
+
'';
+
})