summary refs log tree commit diff
path: root/nixos/modules/services/monitoring/uptime-kuma.nix
diff options
context:
space:
mode:
authorJulien Malka <julien@malka.sh>2022-09-23 07:04:23 +0200
committerRick van Schijndel <Mindavi@users.noreply.github.com>2022-10-23 12:44:16 +0200
commitb54ae5a868d36633d4f4bacd63c06ffb068ff257 (patch)
tree37a0142760df8c3eaa8fd95280bd9a4878d6d33e /nixos/modules/services/monitoring/uptime-kuma.nix
parent2e4f37bbbde742e90cce03929628d40268cd698b (diff)
downloadnixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.tar
nixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.tar.gz
nixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.tar.bz2
nixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.tar.lz
nixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.tar.xz
nixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.tar.zst
nixpkgs-b54ae5a868d36633d4f4bacd63c06ffb068ff257.zip
nixos/uptime-kuma: init module
Diffstat (limited to 'nixos/modules/services/monitoring/uptime-kuma.nix')
-rw-r--r--nixos/modules/services/monitoring/uptime-kuma.nix76
1 files changed, 76 insertions, 0 deletions
diff --git a/nixos/modules/services/monitoring/uptime-kuma.nix b/nixos/modules/services/monitoring/uptime-kuma.nix
new file mode 100644
index 00000000000..3a6091de679
--- /dev/null
+++ b/nixos/modules/services/monitoring/uptime-kuma.nix
@@ -0,0 +1,76 @@
+{ 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;
+      };
+    };
+  };
+}
+