1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8with lib;
9
10let
11 cfg = config.services.whitebophir;
12in
13{
14 options = {
15 services.whitebophir = {
16 enable = mkEnableOption "whitebophir, an online collaborative whiteboard server (persistent state will be maintained under {file}`/var/lib/whitebophir`)";
17
18 package = mkPackageOption pkgs "whitebophir" { };
19
20 listenAddress = mkOption {
21 type = types.str;
22 default = "0.0.0.0";
23 description = "Address to listen on (use 0.0.0.0 to allow access from any address).";
24 };
25
26 port = mkOption {
27 type = types.port;
28 default = 5001;
29 description = "Port to bind to.";
30 };
31 };
32 };
33
34 config = mkIf cfg.enable {
35 systemd.services.whitebophir = {
36 description = "Whitebophir Service";
37 wantedBy = [ "multi-user.target" ];
38 after = [ "network.target" ];
39 environment = {
40 PORT = toString cfg.port;
41 HOST = toString cfg.listenAddress;
42 WBO_HISTORY_DIR = "/var/lib/whitebophir";
43 };
44
45 serviceConfig = {
46 DynamicUser = true;
47 ExecStart = "${cfg.package}/bin/whitebophir";
48 Restart = "always";
49 StateDirectory = "whitebophir";
50 };
51 };
52 };
53}