about summary refs log tree commit diff
path: root/nix/modules/r2wars-web/default.nix
diff options
context:
space:
mode:
authorEmile <git@emile.space>2024-08-16 23:33:53 +0200
committerEmile <git@emile.space>2024-08-16 23:33:53 +0200
commitcea6896788a42c0ea40f99deb4b5987d6741e360 (patch)
tree7b65658ce082cab4f552b0a42fa171745f003bd2 /nix/modules/r2wars-web/default.nix
parentdcfc18774fe2d4207c2996b2d16ea67499b70228 (diff)
big dump, forgot to commit...
Diffstat (limited to 'nix/modules/r2wars-web/default.nix')
-rw-r--r--nix/modules/r2wars-web/default.nix73
1 files changed, 73 insertions, 0 deletions
diff --git a/nix/modules/r2wars-web/default.nix b/nix/modules/r2wars-web/default.nix
new file mode 100644
index 0000000..7e37b26
--- /dev/null
+++ b/nix/modules/r2wars-web/default.nix
@@ -0,0 +1,73 @@
+{ config, lib, pkgs, ... }: 
+
+let
+  cfg = config.services.emile.r2wars-web;
+in with lib; {
+
+  options.services.emile.r2wars-web = {
+    enable = mkEnableOption "Enable r2wars-web";
+
+    # ip and port to listen on
+    host = mkOption {
+      type = types.str;
+      default = "127.0.0.1";
+      example = "0.0.0.0";
+      description = "The host the service listens on";
+    };
+
+    port = mkOption {
+      type = types.int;
+      default = 8080;
+      example = 8080;
+      description = "The port the service listens on";
+    };
+
+    # env vars with secrets to set
+    sessionKey = mkOption {
+      type = types.str;
+      default = "";
+      example = "abc1Itheich4aeQu9Ouz7ahcaiVoogh9";
+      description = "The sessionKey passed to the bin as an env var";
+    };
+
+    salt = mkOption {
+      type = types.str;
+      default = "";
+      example = "OhD0ki5aLieMoowah8Eemaim2beaf2Na";
+      description = "The salt passed to the bin as an env var";
+    };
+
+    # paths to files
+    logfilePath = mkOption {
+      type = types.str;
+      default = "/var/lib/r2wars.log";
+      example = "/var/lib/r2wars.log";
+      description = "The path to the logfile";
+    };
+
+    databasePath = mkOption {
+      type = types.str;
+      default = "/var/lib/main.db";
+      example = "/var/lib/main.db";
+      description = "The path to the main database";
+    };
+
+    sessiondbPath = mkOption {
+      type = types.str;
+      default = "/var/lib/sessions.db";
+      example = "/var/lib/sessions.db";
+      description = "The path to the sessions database";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.r2wars-web = {
+      wantedBy = [ "multi-user.target" ];
+      environment = {
+        SESSION_KEY = cfg.sessionKey;
+        SALT = cfg.salt;
+      };
+      serviceConfig.ExecStart = "${pkgs.r2wars-web}/bin/r2wars-web -h ${cfg.host} -p ${toString cfg.port} --logfilepath ${cfg.logfilePath} --databasepath ${cfg.databasePath} --sessiondbpath ${cfg.sessiondbPath} --templates ${pkgs.r2wars-web}/templates";
+    };
+  };
+}