stockholm/krebs/3modules/brockman.nix
2021-12-01 18:29:24 +01:00

39 lines
1.0 KiB
Nix

{ pkgs, config, ... }:
with import <stockholm/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 = {
home = "/var/lib/brockman";
group = "brockman";
createHome = true;
isSystemUser = true;
uid = genid_uint31 "brockman";
};
users.groups.brockman = {};
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";
RestartSec = 5;
};
};
};
}