8 inherit (lib) mkEnableOption mkOption mkIf types;
9 format = pkgs.formats.toml { };
10 cfg = config.services.hebbot;
11 settingsFile = format.generate "config.toml" cfg.settings;
12 mkTemplateOption = templateName: mkOption {
15 A path to the Markdown file for the ${templateName}.
20 meta.maintainers = [ lib.maintainers.raitobezarius ];
21 options.services.hebbot = {
22 enable = mkEnableOption "hebbot";
23 botPasswordFile = mkOption {
26 A path to the password file for your bot.
28 Consider using a path that does not end up in your Nix store
29 as it would be world readable.
33 project = mkTemplateOption "project template";
34 report = mkTemplateOption "report template";
35 section = mkTemplateOption "section template";
41 Configuration for Hebbot, see, for examples:
43 - <https://github.com/matrix-org/twim-config/blob/master/config.toml>
44 - <https://gitlab.gnome.org/Teams/Websites/thisweek.gnome.org/-/blob/main/hebbot/config.toml>
49 config = mkIf cfg.enable {
50 systemd.services.hebbot = {
51 description = "hebbot - a TWIM-style Matrix bot written in Rust";
52 after = [ "network.target" ];
53 wantedBy = [ "multi-user.target" ];
56 ln -sf ${cfg.templates.project} ./project_template.md
57 ln -sf ${cfg.templates.report} ./report_template.md
58 ln -sf ${cfg.templates.section} ./section_template.md
59 ln -sf ${settingsFile} ./config.toml
63 export BOT_PASSWORD="$(cat $CREDENTIALS_DIRECTORY/bot-password-file)"
64 ${lib.getExe pkgs.hebbot}
69 Restart = "on-failure";
70 LoadCredential = "bot-password-file:${cfg.botPasswordFile}";
72 StateDirectory = "hebbot";
73 WorkingDirectory = "/var/lib/hebbot";