nixos/uptime-kuma: init module

authored by Julien Malka and committed by Rick van Schijndel b54ae5a8 2e4f37bb

+106
+7
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 437 437 <link xlink:href="options.html#opt-services.listmonk.enable">services.listmonk</link>. 438 438 </para> 439 439 </listitem> 440 + <listitem> 441 + <para> 442 + <link xlink:href="https://uptime.kuma.pet/">Uptime 443 + Kuma</link>, a fancy self-hosted monitoring tool. Available as 444 + <link linkend="opt-services.uptime-kuma.enable">services.uptime-kuma</link>. 445 + </para> 446 + </listitem> 440 447 </itemizedlist> 441 448 </section> 442 449 <section xml:id="sec-release-22.11-incompatibilities">
+2
nixos/doc/manual/release-notes/rl-2211.section.md
··· 148 148 149 149 - [Listmonk](https://listmonk.app), a self-hosted newsletter manager. Enable using [services.listmonk](options.html#opt-services.listmonk.enable). 150 150 151 + - [Uptime Kuma](https://uptime.kuma.pet/), a fancy self-hosted monitoring tool. Available as [services.uptime-kuma](#opt-services.uptime-kuma.enable). 152 + 151 153 <!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. --> 152 154 153 155 ## Backward Incompatibilities {#sec-release-22.11-incompatibilities}
+1
nixos/modules/module-list.nix
··· 718 718 ./services/monitoring/ups.nix 719 719 ./services/monitoring/uptime.nix 720 720 ./services/monitoring/vmagent.nix 721 + ./services/monitoring/uptime-kuma.nix 721 722 ./services/monitoring/vnstat.nix 722 723 ./services/monitoring/zabbix-agent.nix 723 724 ./services/monitoring/zabbix-proxy.nix
+76
nixos/modules/services/monitoring/uptime-kuma.nix
··· 1 + { config, pkgs, lib, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.uptime-kuma; 7 + in 8 + { 9 + 10 + options = { 11 + services.uptime-kuma = { 12 + enable = mkEnableOption (mdDoc "Uptime Kuma, this assumes a reverse proxy to be set."); 13 + 14 + package = mkOption { 15 + type = types.package; 16 + example = literalExpression "pkgs.uptime-kuma"; 17 + default = pkgs.uptime-kuma; 18 + defaultText = "pkgs.uptime-kuma"; 19 + description = lib.mdDoc "Uptime Kuma package to use."; 20 + }; 21 + 22 + settings = lib.mkOption { 23 + type = 24 + lib.types.submodule { freeformType = with lib.types; attrsOf str; }; 25 + default = { }; 26 + example = { 27 + PORT = "4000"; 28 + NODE_EXTRA_CA_CERTS = "/etc/ssl/certs/ca-certificates.crt"; 29 + }; 30 + description = lib.mdDoc '' 31 + Additional configuration for Uptime Kuma, see 32 + <https://github.com/louislam/uptime-kuma/wiki/Environment-Variables"> 33 + for supported values. 34 + ''; 35 + }; 36 + }; 37 + }; 38 + 39 + config = mkIf cfg.enable { 40 + 41 + services.uptime-kuma.settings = { 42 + DATA_DIR = "/var/lib/uptime-kuma/"; 43 + NODE_ENV = mkDefault "production"; 44 + }; 45 + 46 + systemd.services.uptime-kuma = { 47 + description = "Uptime Kuma"; 48 + after = [ "network.target" ]; 49 + wantedBy = [ "multi-user.target" ]; 50 + environment = cfg.settings; 51 + serviceConfig = { 52 + Type = "simple"; 53 + StateDirectory = "uptime-kuma"; 54 + DynamicUser = true; 55 + ExecStart = "${cfg.package}/bin/uptime-kuma-server"; 56 + Restart = "on-failure"; 57 + ProtectHome = true; 58 + ProtectSystem = "strict"; 59 + PrivateTmp = true; 60 + PrivateDevices = true; 61 + ProtectHostname = true; 62 + ProtectClock = true; 63 + ProtectKernelTunables = true; 64 + ProtectKernelModules = true; 65 + ProtectKernelLogs = true; 66 + ProtectControlGroups = true; 67 + NoNewPrivileges = true; 68 + RestrictRealtime = true; 69 + RestrictSUIDSGID = true; 70 + RemoveIPC = true; 71 + PrivateMounts = true; 72 + }; 73 + }; 74 + }; 75 + } 76 +
+1
nixos/tests/all-tests.nix
··· 658 658 unit-php = handleTest ./web-servers/unit-php.nix {}; 659 659 upnp = handleTest ./upnp.nix {}; 660 660 uptermd = handleTest ./uptermd.nix {}; 661 + uptime-kuma = handleTest ./uptime-kuma.nix {}; 661 662 usbguard = handleTest ./usbguard.nix {}; 662 663 user-activation-scripts = handleTest ./user-activation-scripts.nix {}; 663 664 user-home-mode = handleTest ./user-home-mode.nix {};
+19
nixos/tests/uptime-kuma.nix
··· 1 + import ./make-test-python.nix ({ lib, ... }: 2 + 3 + with lib; 4 + 5 + { 6 + name = "uptime-kuma"; 7 + meta.maintainers = with maintainers; [ julienmalka ]; 8 + 9 + nodes.machine = 10 + { pkgs, ... }: 11 + { services.uptime-kuma.enable = true; }; 12 + 13 + testScript = '' 14 + machine.start() 15 + machine.wait_for_unit("uptime-kuma.service") 16 + machine.wait_for_open_port(3001) 17 + machine.succeed("curl --fail http://localhost:3001/") 18 + ''; 19 + })