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