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