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