1 { config, lib, pkgs, ... }:
7 cfg = config.services.sabnzbd;
8 inherit (pkgs) sabnzbd;
18 enable = mkEnableOption "the sabnzbd server";
20 package = mkPackageOption pkgs "sabnzbd" { };
22 configFile = mkOption {
24 default = "/var/lib/sabnzbd/sabnzbd.ini";
25 description = "Path to config file.";
31 description = "User to run the service as";
37 description = "Group to run the service as";
40 openFirewall = mkOption {
44 Open ports in the firewall for the sabnzbd web interface
53 config = mkIf cfg.enable {
54 users.users = mkIf (cfg.user == "sabnzbd") {
56 uid = config.ids.uids.sabnzbd;
58 description = "sabnzbd user";
62 users.groups = mkIf (cfg.group == "sabnzbd") {
63 sabnzbd.gid = config.ids.gids.sabnzbd;
66 systemd.services.sabnzbd = {
67 description = "sabnzbd server";
68 wantedBy = [ "multi-user.target" ];
69 after = [ "network.target" ];
75 StateDirectory = "sabnzbd";
76 ExecStart = "${lib.getBin cfg.package}/bin/sabnzbd -d -f ${cfg.configFile}";
80 networking.firewall = mkIf cfg.openFirewall {
81 allowedTCPPorts = [ 8080 ];