summaryrefslogtreecommitdiffstats
path: root/krebs/3modules/brockman.nix
blob: 21cc14202fc4c7f432bf8eebb5bfe37158fe0d12 (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
{ pkgs, lib, config, ... }:
with lib;
let
  cfg = config.krebs.brockman;
in {
  options.krebs.brockman = {
    enable = mkEnableOption "brockman";
    config = mkOption { type = types.attrs; }; # TODO make real config here
  };

  config = mkIf cfg.enable {
    users.extraUsers.brockman.isNormalUser = false;

    systemd.services.brockman = {
      description = "RSS to IRC broadcaster";
      wantedBy = [ "multi-user.target" ];
      after = [ "network-online.target" ];
      serviceConfig = {
        Restart = "always";
        ExecStart = ''
          ${pkgs.brockman}/bin/brockman ${pkgs.writeText "brockman.json" (builtins.toJSON cfg.config)}
        '';
        User = config.users.extraUsers.brockman.name;
        PrivateTmp = true;
        RuntimeDirectory = "brockman";
        WorkingDirectory = "%t/brockman";
      };
    };
  };
}