@@ -17,11 +17,21 @@ in
1717 services.sabnzbd = {
1818 enable = mkOption {
1919 default = false;
20− description = "Whether to enable the sabnzbd FTP server.";
20+ description = "Whether to enable the sabnzbd server.";
2121 };
2222 configFile = mkOption {
23− default = "/var/sabnzbd/sabnzbd.ini";
24− description = "Path to config file. (You need to create this file yourself!)";
23+ default = "/var/lib/sabnzbd/sabnzbd.ini";
24+ description = "Path to config file.";
25+ };
26+
27+ user = mkOption {
28+ default = "sabnzbd";
29+ description = "User to run the service as";
30+ };
31+
32+ group = mkOption {
33+ default = "sabnzbd";
34+ description = "Group to run the service as";
2535 };
2636 };
2737 };
@@ -31,23 +41,29 @@ in
3141
3242 config = mkIf cfg.enable {
3343
34− users.extraUsers =
35− [ { name = "sabnzbd";
44+ users.extraUsers.sabnzbd = {
3645 uid = config.ids.uids.sabnzbd;
46+ group = "sabnzbd";
3747 description = "sabnzbd user";
38− home = "/homeless-shelter";
39− }
40− ];
48+ home = "/var/lib/sabnzbd/";
49+ createHome = true;
50+ };
4151
42− systemd.services.sabnzbd =
43− { description = "sabnzbd server";
52+ users.extraGroups.sabnzbd = {
53+ gid = config.ids.gids.sabnzbd;
54+ };
55+
56+ systemd.services.sabnzbd = {
57+ description = "sabnzbd server";
4458 wantedBy = [ "multi-user.target" ];
4559 after = [ "network.target" ];
4660 serviceConfig = {
4761 Type = "forking";
62+ GuessMainPID = "no";
63+ User = "${cfg.user}";
64+ Group = "${cfg.group}";
4865 ExecStart = "${sabnzbd}/bin/sabnzbd -d -f ${cfg.configFile}";
4966 };
50− };
51−
67+ };
5268 };
5369}