nixos/services.sonarr: remove with lib;
This commit is contained in:
parent
b84a9d0112
commit
7abfa8873a
@ -1,46 +1,43 @@
|
|||||||
{ config, pkgs, lib, utils, ... }:
|
{ config, pkgs, lib, utils, ... }:
|
||||||
|
|
||||||
with lib;
|
|
||||||
|
|
||||||
let
|
let
|
||||||
cfg = config.services.sonarr;
|
cfg = config.services.sonarr;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
services.sonarr = {
|
services.sonarr = {
|
||||||
enable = mkEnableOption "Sonarr";
|
enable = lib.mkEnableOption "Sonarr";
|
||||||
|
|
||||||
dataDir = mkOption {
|
dataDir = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "/var/lib/sonarr/.config/NzbDrone";
|
default = "/var/lib/sonarr/.config/NzbDrone";
|
||||||
description = "The directory where Sonarr stores its data files.";
|
description = "The directory where Sonarr stores its data files.";
|
||||||
};
|
};
|
||||||
|
|
||||||
openFirewall = mkOption {
|
openFirewall = lib.mkOption {
|
||||||
type = types.bool;
|
type = lib.types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
Open ports in the firewall for the Sonarr web interface
|
Open ports in the firewall for the Sonarr web interface
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
user = mkOption {
|
user = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "sonarr";
|
default = "sonarr";
|
||||||
description = "User account under which Sonaar runs.";
|
description = "User account under which Sonaar runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
group = mkOption {
|
group = lib.mkOption {
|
||||||
type = types.str;
|
type = lib.types.str;
|
||||||
default = "sonarr";
|
default = "sonarr";
|
||||||
description = "Group under which Sonaar runs.";
|
description = "Group under which Sonaar runs.";
|
||||||
};
|
};
|
||||||
|
|
||||||
package = mkPackageOption pkgs "sonarr" { };
|
package = lib.mkPackageOption pkgs "sonarr" { };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
|
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
|
||||||
];
|
];
|
||||||
@ -63,11 +60,11 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
networking.firewall = mkIf cfg.openFirewall {
|
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||||
allowedTCPPorts = [ 8989 ];
|
allowedTCPPorts = [ 8989 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
users.users = mkIf (cfg.user == "sonarr") {
|
users.users = lib.mkIf (cfg.user == "sonarr") {
|
||||||
sonarr = {
|
sonarr = {
|
||||||
group = cfg.group;
|
group = cfg.group;
|
||||||
home = cfg.dataDir;
|
home = cfg.dataDir;
|
||||||
@ -75,7 +72,7 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
users.groups = mkIf (cfg.group == "sonarr") {
|
users.groups = lib.mkIf (cfg.group == "sonarr") {
|
||||||
sonarr.gid = config.ids.gids.sonarr;
|
sonarr.gid = config.ids.gids.sonarr;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user