~sumner/nixos-configuration

ref: f4eb6417bc48729411263dc754fbe8c63a65d5bf nixos-configuration/modules/services/matrix/standupbot.nix -rw-r--r-- 1.5 KiB
f4eb6417Sumner Evans standupbot: 0.4.1rc2 0.4.1rc3 8 months ago
                                                                                
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
51
52
53
54
55
56
57
58
59
60
{ config, lib, pkgs, ... }: with lib; let
  cfg = config.services.standupbot;
  standupbot = pkgs.callPackage ../../../pkgs/standupbot {};

  standupbotConfig = {
    Username = cfg.username;
    Homeserver = cfg.homeserver;
    PasswordFile = cfg.passwordFile;
  };
  format = pkgs.formats.json {};
  standupbotConfigJson = format.generate "standupbot.config.json" standupbotConfig;
in
{
  options = {
    services.standupbot = {
      enable = mkEnableOption "standupbot";
      username = mkOption {
        type = types.str;
        default = "@standupbot:${config.networking.domain}";
      };
      homeserver = mkOption {
        type = types.str;
        default = "http://localhost:8008";
      };
      passwordFile = mkOption {
        type = types.path;
        default = "/var/lib/standupbot/passwordfile";
      };
      dataDir = mkOption {
        type = types.path;
        default = "/var/lib/standupbot";
      };
    };
  };

  config = mkIf cfg.enable {
    systemd.services.standupbot = {
      description = "Standupbot";
      after = [ "matrix-synapse.service" ];
      wantedBy = [ "multi-user.target" ];
      serviceConfig = {
        ExecStart = ''
          ${standupbot}/bin/standupbot --config ${standupbotConfigJson}
        '';
        Restart = "on-failure";
        User = "standupbot";
      };
    };

    users = {
      users.standupbot = {
        group = "standupbot";
        isSystemUser = true;
        home = cfg.dataDir;
        createHome = true;
      };
      groups.standupbot = {};
    };
  };
}