about summary refs log tree commit diff
path: root/nixos/modules/services/web-apps/phylactery.nix
diff options
context:
space:
mode:
authorNguyễn Gia Phong <mcsinyx@disroot.org>2022-06-28 16:41:44 +0900
committerNguyễn Gia Phong <mcsinyx@disroot.org>2022-06-30 22:50:08 +0900
commitf5f338c8468a84b624980c2fd2cf2fa32d14741b (patch)
treecab22aed5a49e5ca3cfb4196793a9d240345777e /nixos/modules/services/web-apps/phylactery.nix
parent512670498f288c98279bfae0910a2811b9dd51e2 (diff)
nixos/phylactery: init
Diffstat (limited to 'nixos/modules/services/web-apps/phylactery.nix')
-rw-r--r--nixos/modules/services/web-apps/phylactery.nix51
1 files changed, 51 insertions, 0 deletions
diff --git a/nixos/modules/services/web-apps/phylactery.nix b/nixos/modules/services/web-apps/phylactery.nix
new file mode 100644
index 0000000000000..f0e97da1f2023
--- /dev/null
+++ b/nixos/modules/services/web-apps/phylactery.nix
@@ -0,0 +1,51 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let cfg = config.services.phylactery;
+in {
+  options.services.phylactery = {
+    enable = mkEnableOption "Whether to enable Phylactery server";
+
+    host = mkOption {
+      type = types.str;
+      default = "localhost";
+      description = "Listen host for Phylactery";
+    };
+
+    port = mkOption {
+      type = types.port;
+      description = "Listen port for Phylactery";
+    };
+
+    library = mkOption {
+      type = types.path;
+      description = "Path to CBZ library";
+    };
+
+    package = mkOption {
+      type = types.package;
+      default = pkgs.phylactery;
+      defaultText = literalExpression "pkgs.phylactery";
+      description = "The Phylactery package to use";
+    };
+  };
+
+  config = mkIf cfg.enable {
+    systemd.services.phylactery = {
+      environment = {
+        PHYLACTERY_ADDRESS = "${cfg.host}:${toString cfg.port}";
+        PHYLACTERY_LIBRARY = "${cfg.library}";
+      };
+
+      wantedBy = [ "multi-user.target" ];
+
+      serviceConfig = {
+        ConditionPathExists = cfg.library;
+        DynamicUser = true;
+        ExecStart = "${cfg.package}/bin/phylactery";
+      };
+    };
+  };
+
+  meta.maintainers = with maintainers; [ McSinyx ];
+}