1{ config, lib, pkgs, ... }:
2
3with lib;
4let cfg = config.services.phylactery;
5in {
6 options.services.phylactery = {
7 enable = mkEnableOption (lib.mdDoc "Whether to enable Phylactery server");
8
9 host = mkOption {
10 type = types.str;
11 default = "localhost";
12 description = lib.mdDoc "Listen host for Phylactery";
13 };
14
15 port = mkOption {
16 type = types.port;
17 description = lib.mdDoc "Listen port for Phylactery";
18 };
19
20 library = mkOption {
21 type = types.path;
22 description = lib.mdDoc "Path to CBZ library";
23 };
24
25 package = mkOption {
26 type = types.package;
27 default = pkgs.phylactery;
28 defaultText = literalExpression "pkgs.phylactery";
29 description = lib.mdDoc "The Phylactery package to use";
30 };
31 };
32
33 config = mkIf cfg.enable {
34 systemd.services.phylactery = {
35 environment = {
36 PHYLACTERY_ADDRESS = "${cfg.host}:${toString cfg.port}";
37 PHYLACTERY_LIBRARY = "${cfg.library}";
38 };
39
40 wantedBy = [ "multi-user.target" ];
41
42 serviceConfig = {
43 ConditionPathExists = cfg.library;
44 DynamicUser = true;
45 ExecStart = "${cfg.package}/bin/phylactery";
46 };
47 };
48 };
49
50 meta.maintainers = with maintainers; [ McSinyx ];
51}