summary refs log tree commit diff
diff options
context:
space:
mode:
authorStephen Weinberg <stephen@q5comm.com>2015-05-01 12:38:00 -0700
committerStephen Weinberg <stephen@q5comm.com>2015-05-05 00:18:22 -0400
commita6ebccfbb879640e6a1ab406b4061bac492e789f (patch)
tree881a1724e5ac3d4d328ddd87810d1c31836d916f
parent7556fe4cf6fa4df77e96a238b6c12b10fbe991d8 (diff)
downloadnixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.tar
nixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.tar.gz
nixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.tar.bz2
nixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.tar.lz
nixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.tar.xz
nixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.tar.zst
nixpkgs-a6ebccfbb879640e6a1ab406b4061bac492e789f.zip
Sane default configuration for sabnzbd module
Added option to set user. Use unpriviledged user by default. Add sane
default for configuration location.
-rw-r--r--nixos/modules/misc/ids.nix1
-rw-r--r--nixos/modules/services/networking/sabnzbd.nix40
2 files changed, 29 insertions, 12 deletions
diff --git a/nixos/modules/misc/ids.nix b/nixos/modules/misc/ids.nix
index 0319c5688fb..0039ca74ba8 100644
--- a/nixos/modules/misc/ids.nix
+++ b/nixos/modules/misc/ids.nix
@@ -411,6 +411,7 @@
       lambdabot = 191;
       #asterisk = 192; # unused
       plex = 193;
+      sabnzbd = 194;
 
       # When adding a gid, make sure it doesn't match an existing
       # uid. Users and groups with the same name should have equal
diff --git a/nixos/modules/services/networking/sabnzbd.nix b/nixos/modules/services/networking/sabnzbd.nix
index 77bf64b80d0..cacf753fdcd 100644
--- a/nixos/modules/services/networking/sabnzbd.nix
+++ b/nixos/modules/services/networking/sabnzbd.nix
@@ -17,11 +17,21 @@ in
     services.sabnzbd = {
       enable = mkOption {
         default = false;
-        description = "Whether to enable the sabnzbd FTP server.";
+        description = "Whether to enable the sabnzbd server.";
       };
       configFile = mkOption {
-        default = "/var/sabnzbd/sabnzbd.ini";
-        description = "Path to config file. (You need to create this file yourself!)";
+        default = "/var/lib/sabnzbd/sabnzbd.ini";
+        description = "Path to config file.";
+      };
+
+      user = mkOption {
+        default = "sabnzbd";
+        description = "User to run the service as";
+      };
+
+      group = mkOption {
+        default = "sabnzbd";
+        description = "Group to run the service as";
       };
     };
   };
@@ -31,23 +41,29 @@ in
 
   config = mkIf cfg.enable {
 
-    users.extraUsers =
-      [ { name = "sabnzbd";
+    users.extraUsers.sabnzbd = {
           uid = config.ids.uids.sabnzbd;
+          group = "sabnzbd";
           description = "sabnzbd user";
-          home = "/homeless-shelter";
-        }
-      ];
+          home = "/var/lib/sabnzbd/";
+          createHome = true;
+    };
 
-    systemd.services.sabnzbd =
-      { description = "sabnzbd server";
+    users.extraGroups.sabnzbd = {
+      gid = config.ids.gids.sabnzbd;
+    };
+
+    systemd.services.sabnzbd = {
+        description = "sabnzbd server";
         wantedBy    = [ "multi-user.target" ];
         after = [ "network.target" ];
         serviceConfig = {
           Type = "forking";
+          GuessMainPID = "no";
+          User = "${cfg.user}";
+          Group = "${cfg.group}";
           ExecStart = "${sabnzbd}/bin/sabnzbd -d -f ${cfg.configFile}";
         };
-      };
-
+    };
   };
 }