1{
2 config,
3 lib,
4 pkgs,
5 ...
6}:
7
8let
9
10 inherit (lib)
11 mkIf
12 mkEnableOption
13 mkOption
14 types
15 literalExpression
16 ;
17 cfg = config.services.nextcloud-whiteboard-server;
18
19in
20{
21 options.services.nextcloud-whiteboard-server = {
22
23 enable = mkEnableOption "Nextcloud backend server for the Whiteboard app";
24
25 settings = mkOption {
26 type = types.attrsOf types.str;
27 default = { };
28 description = ''
29 Settings to configure backend server. Especially the Nextcloud host
30 url has to be set. The required environment variable `JWT_SECRET_KEY`
31 should be set via the secrets option.
32 '';
33 example = literalExpression ''
34 {
35 NEXTCLOUD_URL = "https://nextcloud.example.org";
36 }
37 '';
38 };
39
40 secrets = lib.mkOption {
41 type = with types; listOf str;
42 description = ''
43 A list of files containing the various secrets. Should be in the
44 format expected by systemd's `EnvironmentFile` directory.
45 '';
46 default = [ ];
47 };
48
49 };
50
51 config = mkIf cfg.enable {
52
53 systemd.services.nextcloud-whiteboard-server = {
54 description = "Nextcloud backend server for the Whiteboard app";
55 wantedBy = [ "multi-user.target" ];
56 after = [ "network-online.target" ];
57 wants = [ "network-online.target" ];
58 environment = cfg.settings;
59 serviceConfig = {
60 ExecStart = "${lib.getExe pkgs.nextcloud-whiteboard-server}";
61 WorkingDirectory = "%S/whiteboard";
62 StateDirectory = "whiteboard";
63 EnvironmentFile = [ cfg.secrets ];
64 DynamicUser = true;
65 };
66 };
67
68 };
69
70 meta.maintainers = with lib.maintainers; [ onny ];
71
72}