summary refs log tree commit diff
path: root/modules/services/networking/supybot.nix
diff options
context:
space:
mode:
authorCillian de Róiste <goibhniu@fsfe.org>2013-08-04 03:56:01 +0200
committerCillian de Róiste <goibhniu@fsfe.org>2013-08-04 03:56:01 +0200
commit5b25c5a18145e47fe27602b4cb721228edd6a1aa (patch)
tree8ce1db386d8c6661f2e903968d2fad18ee667eb6 /modules/services/networking/supybot.nix
parent6e093113fe50a55fb055d0819d2bca797c140d64 (diff)
downloadnixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.tar
nixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.tar.gz
nixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.tar.bz2
nixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.tar.lz
nixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.tar.xz
nixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.tar.zst
nixpkgs-5b25c5a18145e47fe27602b4cb721228edd6a1aa.zip
supybot.service: tidy up
Diffstat (limited to 'modules/services/networking/supybot.nix')
-rw-r--r--modules/services/networking/supybot.nix100
1 files changed, 44 insertions, 56 deletions
diff --git a/modules/services/networking/supybot.nix b/modules/services/networking/supybot.nix
index 944e5828fe0..fa8b7556de5 100644
--- a/modules/services/networking/supybot.nix
+++ b/modules/services/networking/supybot.nix
@@ -10,8 +10,6 @@ in
 
 {
 
-  ###### interface
-
   options = {
 
     services.supybot = {
@@ -22,29 +20,20 @@ in
       };
 
       stateDir = mkOption {
-        default = "/var/lib/supybot";
-        description = "
-
-        ";
+        # Setting this to /var/lib/supybot caused useradd to fail
+        default = "/home/supybot";
+        description = "The root directory, logs and plugins are stored here";
       };
 
       configFile = mkOption {
         type = types.path;
-        default = /dev/null;
         description = ''
-          Verbatim contents of the supybot config, this can be
-          generated by supybot-wizard
-        '';
-      };
+          Path to a supybot config file. This can be generated by
+          running supybot-wizard.
 
-      user = mkOption {
-        default = "supybot";
-        description = "User account under which supybot runs.";
-      };
-
-      group = mkOption {
-        default = "supybot";
-        description = "Group account under which supybot runs.";
+          Note: all paths should include the full path to the stateDir
+          directory (backup conf data logs logs/plugins plugins tmp web).
+        '';
       };
 
     };
@@ -52,49 +41,48 @@ in
   };
 
 
-  ###### 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.stateDir;
-        createHome = true;
-      };
+    users.extraUsers = singleton {
+      name = "supybot";
+      uid = config.ids.uids.supybot;
+      group = "supybot";
+      description = "Supybot IRC bot user";
+      home = cfg.stateDir;
+      createHome = true;
+    };
 
-    users.extraGroups.supybot = {};
-
-    systemd.services.supybot =
-      { description = "Supybot IRC bot";
-        after = [ "network.target" ];
-        wantedBy = [ "multi-user.target" ];
-        path = [ pkgs.pythonPackages.limnoria ];
-        preStart = ''
-          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.stateDir}/supybot.cfg";
-            PIDFile = "/run/supybot.pid";
-            User = "${cfg.user}";
-            Group = "${cfg.group}";
-            UMask = "0007";
-            Restart = "on-abort";
-            StartLimitInterval = "5m";
-            StartLimitBurst = "1";
-          };
+    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";
       };
+    };
 
   };
-
 }