nixpkgs/nixos/modules/services/networking/supybot.nix

89 lines
2.0 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
2013-07-31 22:36:15 +00:00
with lib;
2013-07-31 22:36:15 +00:00
let
cfg = config.services.supybot;
in
{
options = {
services.supybot = {
enable = mkOption {
default = false;
description = "Enable Supybot, an IRC bot";
2013-07-31 22:36:15 +00:00
};
stateDir = mkOption {
2013-08-04 01:56:01 +00:00
# Setting this to /var/lib/supybot caused useradd to fail
default = "/home/supybot";
description = "The root directory, logs and plugins are stored here";
2013-07-31 22:36:15 +00:00
};
configFile = mkOption {
type = types.path;
2013-07-31 22:36:15 +00:00
description = ''
2013-08-04 01:56:01 +00:00
Path to a supybot config file. This can be generated by
running supybot-wizard.
2013-07-31 22:36:15 +00:00
2013-08-04 01:56:01 +00:00
Note: all paths should include the full path to the stateDir
directory (backup conf data logs logs/plugins plugins tmp web).
'';
2013-07-31 22:36:15 +00:00
};
};
};
config = mkIf cfg.enable {
2013-07-31 22:36:15 +00:00
environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
2013-08-04 01:56:01 +00:00
users.extraUsers = singleton {
name = "supybot";
uid = config.ids.uids.supybot;
group = "supybot";
description = "Supybot IRC bot user";
home = cfg.stateDir;
createHome = true;
};
2013-07-31 22:36:15 +00:00
2013-08-04 01:56:01 +00:00
users.extraGroups.supybot = {
name = "supybot";
gid = config.ids.gids.supybot;
};
systemd.services.supybot = {
description = "Supybot, an IRC bot";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
path = [ pkgs.pythonPackages.limnoria ];
preStart = ''
cd ${cfg.stateDir}
mkdir -p backup conf data plugins logs/plugins tmp web
ln -sf ${cfg.configFile} supybot.cfg
# This needs to be created afresh every time
rm -f supybot.cfg.bak
'';
serviceConfig = {
ExecStart = "${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.stateDir}/supybot.cfg";
PIDFile = "/run/supybot.pid";
User = "supybot";
Group = "supybot";
UMask = "0007";
Restart = "on-abort";
StartLimitInterval = "5m";
StartLimitBurst = "1";
2013-07-31 22:36:15 +00:00
};
2013-08-04 01:56:01 +00:00
};
2013-07-31 22:36:15 +00:00
};
}