aboutsummaryrefslogtreecommitdiff
path: root/nix/module.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix/module.nix')
-rw-r--r--nix/module.nix32
1 files changed, 32 insertions, 0 deletions
diff --git a/nix/module.nix b/nix/module.nix
index 5b59937..09857a2 100644
--- a/nix/module.nix
+++ b/nix/module.nix
@@ -47,6 +47,12 @@ in {
default = null;
};
+ restartTimer = mkOption {
+ description = "restart on timer";
+ type = nullOr str;
+ default = null;
+ };
+
postgres = mkOption {
description = "local postgres server with automatic setup";
@@ -155,6 +161,32 @@ in {
};
};
+ systemd.timers.thulani-restart = lib.mkIf (cfg.restartTimer != null) {
+ wantedBy = ["timers.target"];
+
+ timerConfig = {
+ OnCalendar = cfg.restartTimer;
+ Unit = "thulani-restart.service";
+ };
+ };
+
+ systemd.services.thulani-restart = lib.mkIf (cfg.restartTimer != null) {
+ description = "restart thulani bot";
+
+ serviceConfig = {
+ Type = "oneshot";
+ };
+
+ script = ''
+ set -euo pipefail
+
+ if systemctl is-active thulani.service; then
+ exec systemctl restart --no-block thulani.service
+ fi
+ '';
+ };
+
+
services.postgresql = lib.mkIf cfg.postgres.enable {
enable = true;