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