Sane default configuration for sabnzbd module

Added option to set user. Use unpriviledged user by default. Add sane
default for configuration location.

+29 -12
+1
nixos/modules/misc/ids.nix
··· 411 411 lambdabot = 191; 412 412 #asterisk = 192; # unused 413 413 plex = 193; 414 + sabnzbd = 194; 414 415 415 416 # When adding a gid, make sure it doesn't match an existing 416 417 # uid. Users and groups with the same name should have equal
+28 -12
nixos/modules/services/networking/sabnzbd.nix
··· 17 17 services.sabnzbd = { 18 18 enable = mkOption { 19 19 default = false; 20 - description = "Whether to enable the sabnzbd FTP server."; 20 + description = "Whether to enable the sabnzbd server."; 21 21 }; 22 22 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"; 25 35 }; 26 36 }; 27 37 }; ··· 31 41 32 42 config = mkIf cfg.enable { 33 43 34 - users.extraUsers = 35 - [ { name = "sabnzbd"; 44 + users.extraUsers.sabnzbd = { 36 45 uid = config.ids.uids.sabnzbd; 46 + group = "sabnzbd"; 37 47 description = "sabnzbd user"; 38 - home = "/homeless-shelter"; 39 - } 40 - ]; 48 + home = "/var/lib/sabnzbd/"; 49 + createHome = true; 50 + }; 41 51 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"; 44 58 wantedBy = [ "multi-user.target" ]; 45 59 after = [ "network.target" ]; 46 60 serviceConfig = { 47 61 Type = "forking"; 62 + GuessMainPID = "no"; 63 + User = "${cfg.user}"; 64 + Group = "${cfg.group}"; 48 65 ExecStart = "${sabnzbd}/bin/sabnzbd -d -f ${cfg.configFile}"; 49 66 }; 50 - }; 51 - 67 + }; 52 68 }; 53 69 }