about summary refs log tree commit diff
path: root/nix/modules/remarvin/default.nix
blob: d9e449a9809a5facfcaaba571a0452d627548924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.services.emile.remarvin;
in
with lib;
{
  options.services.emile.remarvin = {
    enable = mkEnableOption "Enable remarvin";

    # env vars with secrets to set
    username = mkOption {
      type = types.str;
      default = "";
      example = "remarvin";
      description = "The username of the bot (without @ or homeserver)";
    };

    homeserver = mkOption {
      type = types.str;
      default = "";
      example = "matrix.org";
      description = "The homeserver to use";
    };

    accesstokenpath = mkOption {
      type = types.str;
      default = "";
      example = "/secret/remarvin_accesstoken";
      description = "The path to the accesstoken used (element web > settings > help & about > advanced > access token)";
    };
  };

  config = mkIf cfg.enable {
    systemd.services.remarvin = {
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        RestartSec = 5;
        Restart = "always";
      };
      path = [ pkgs.remarvin ];
      serviceConfig.ExecStart = "${pkgs.remarvin}/bin/remarvin -homeserver ${cfg.homeserver} -username ${cfg.username} -accesstokenpath ${cfg.accesstokenpath}";
    };
  };
}