diff --git a/modules/misc/ids.nix b/modules/misc/ids.nix index 7272c3e7d5d0..54c9b331adef 100644 --- a/modules/misc/ids.nix +++ b/modules/misc/ids.nix @@ -76,6 +76,7 @@ in nslcd = 58; nginx = 60; chrony = 61; + supybot = 62; # When adding a uid, make sure it doesn't match an existing gid. diff --git a/modules/module-list.nix b/modules/module-list.nix index ebe66d1fa6e9..4f014c9d348d 100644 --- a/modules/module-list.nix +++ b/modules/module-list.nix @@ -169,6 +169,7 @@ ./services/networking/rdnssd.nix ./services/networking/rpcbind.nix ./services/networking/sabnzbd.nix + ./services/networking/supybot.nix ./services/networking/ssh/lshd.nix ./services/networking/ssh/sshd.nix ./services/networking/tftpd.nix diff --git a/modules/services/networking/supybot.nix b/modules/services/networking/supybot.nix new file mode 100644 index 000000000000..f65665e41e48 --- /dev/null +++ b/modules/services/networking/supybot.nix @@ -0,0 +1,97 @@ +{ config, pkgs, ... }: + +with pkgs.lib; + +let + + cfg = config.services.supybot; + configFile = pkgs.writeText "supybot.cfg" cfg.config; + +in + +{ + + ###### interface + + options = { + + services.supybot = { + + enable = mkOption { + default = false; + description = "Enable the supybot IRC bot"; + }; + + homeDir = mkOption { + default = "/home/supybot"; + description = " + Directory holding all state for nginx to run. + "; + }; + + config = mkOption { + type = types.lines; + default = ""; + description = '' + Verbatim contents of the supybot config, this can be + generated by supybot-wizard + ''; + }; + + user = mkOption { + default = "supybot"; + description = "User account under which supybot runs."; + }; + + group = mkOption { + default = "supybot"; + description = "Group account under which supybot runs."; + }; + + }; + + }; + + + ###### implementation + + config = mkIf cfg.enable { + + environment.systemPackages = [ pkgs.pythonPackages.limnoria ]; + + users.extraUsers = singleton + { name = cfg.user; + uid = config.ids.uids.supybot; + group = "supybot"; + description = "Supybot IRC bot user"; + home = cfg.homeDir; + createHome = true; + }; + + users.extraGroups.supybot = {}; + + systemd.services.supybot = + { description = "Supybot IRC bot"; + after = [ "network.target" ]; + wantedBy = [ "multi-user.target" ]; + path = [ pkgs.pythonPackages.limnoria ]; + preStart = '' + cd ${cfg.homeDir} + mkdir -p logs/plugins backup conf data plugins tmp + ''; + serviceConfig = + { ExecStart = + "${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.homeDir}/supybot.cfg"; + PIDFile = "/run/supybot.pid"; + User = "${cfg.user}"; + Group = "${cfg.group}"; + UMask = "0007"; + Restart = "on-abort"; + StartLimitInterval = "5m"; + StartLimitBurst = "1"; + }; + }; + + }; + +}