summary refs log tree commit diff
path: root/modules/services/networking/supybot.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/services/networking/supybot.nix')
-rw-r--r--modules/services/networking/supybot.nix31
1 files changed, 17 insertions, 14 deletions
diff --git a/modules/services/networking/supybot.nix b/modules/services/networking/supybot.nix
index f65665e41e4..944e5828fe0 100644
--- a/modules/services/networking/supybot.nix
+++ b/modules/services/networking/supybot.nix
@@ -5,7 +5,6 @@ with pkgs.lib;
 let
 
   cfg  = config.services.supybot;
-  configFile = pkgs.writeText "supybot.cfg" cfg.config;
 
 in
 
@@ -19,19 +18,19 @@ in
 
       enable = mkOption {
         default = false;
-        description = "Enable the supybot IRC bot";
+        description = "Enable Supybot, an IRC bot";
       };
 
-      homeDir = mkOption {
-        default = "/home/supybot";
+      stateDir = mkOption {
+        default = "/var/lib/supybot";
         description = "
-          Directory holding all state for nginx to run.
+
         ";
       };
 
-      config = mkOption {
-        type = types.lines;
-        default = "";
+      configFile = mkOption {
+        type = types.path;
+        default = /dev/null;
         description = ''
           Verbatim contents of the supybot config, this can be
           generated by supybot-wizard
@@ -56,7 +55,7 @@ in
   ###### implementation
 
   config = mkIf cfg.enable {
-  
+
     environment.systemPackages = [ pkgs.pythonPackages.limnoria ];
 
     users.extraUsers = singleton
@@ -64,9 +63,9 @@ in
         uid = config.ids.uids.supybot;
         group = "supybot";
         description = "Supybot IRC bot user";
-        home = cfg.homeDir;
+        home = cfg.stateDir;
         createHome = true;
-      }; 
+      };
 
     users.extraGroups.supybot = {};
 
@@ -76,14 +75,18 @@ in
         wantedBy = [ "multi-user.target" ];
         path = [ pkgs.pythonPackages.limnoria ];
         preStart = ''
-          cd ${cfg.homeDir}
+          mkdir -m 0755 -p ${cfg.stateDir}
+          chown ${cfg.user}:${cfg.group} ${cfg.stateDir}
+          cd ${cfg.stateDir}
           mkdir -p logs/plugins backup conf data plugins tmp
+          ln -sf ${cfg.configFile} supybot.cfg
+          rm -f supybot.cfg.bak
         '';
         serviceConfig =
           { ExecStart =
-              "${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.homeDir}/supybot.cfg";
+              "${pkgs.pythonPackages.limnoria}/bin/supybot ${cfg.stateDir}/supybot.cfg";
             PIDFile = "/run/supybot.pid";
-            User = "${cfg.user}"; 
+            User = "${cfg.user}";
             Group = "${cfg.group}";
             UMask = "0007";
             Restart = "on-abort";