nixos/services.radarr: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-30 00:46:43 +02:00
parent f5c2c7bbf2
commit 39d9937d05

View File

@ -1,7 +1,4 @@
{ config, pkgs, lib, ... }: { config, pkgs, lib, ... }:
with lib;
let let
cfg = config.services.radarr; cfg = config.services.radarr;
@ -9,37 +6,37 @@ in
{ {
options = { options = {
services.radarr = { services.radarr = {
enable = mkEnableOption "Radarr, a UsetNet/BitTorrent movie downloader"; enable = lib.mkEnableOption "Radarr, a UsetNet/BitTorrent movie downloader";
package = mkPackageOption pkgs "radarr" { }; package = lib.mkPackageOption pkgs "radarr" { };
dataDir = mkOption { dataDir = lib.mkOption {
type = types.str; type = lib.types.str;
default = "/var/lib/radarr/.config/Radarr"; default = "/var/lib/radarr/.config/Radarr";
description = "The directory where Radarr stores its data files."; description = "The directory where Radarr stores its data files.";
}; };
openFirewall = mkOption { openFirewall = lib.mkOption {
type = types.bool; type = lib.types.bool;
default = false; default = false;
description = "Open ports in the firewall for the Radarr web interface."; description = "Open ports in the firewall for the Radarr web interface.";
}; };
user = mkOption { user = lib.mkOption {
type = types.str; type = lib.types.str;
default = "radarr"; default = "radarr";
description = "User account under which Radarr runs."; description = "User account under which Radarr runs.";
}; };
group = mkOption { group = lib.mkOption {
type = types.str; type = lib.types.str;
default = "radarr"; default = "radarr";
description = "Group under which Radarr runs."; description = "Group under which Radarr runs.";
}; };
}; };
}; };
config = mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.tmpfiles.settings."10-radarr".${cfg.dataDir}.d = { systemd.tmpfiles.settings."10-radarr".${cfg.dataDir}.d = {
inherit (cfg) user group; inherit (cfg) user group;
mode = "0700"; mode = "0700";
@ -59,11 +56,11 @@ in
}; };
}; };
networking.firewall = mkIf cfg.openFirewall { networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 7878 ]; allowedTCPPorts = [ 7878 ];
}; };
users.users = mkIf (cfg.user == "radarr") { users.users = lib.mkIf (cfg.user == "radarr") {
radarr = { radarr = {
group = cfg.group; group = cfg.group;
home = cfg.dataDir; home = cfg.dataDir;
@ -71,7 +68,7 @@ in
}; };
}; };
users.groups = mkIf (cfg.group == "radarr") { users.groups = lib.mkIf (cfg.group == "radarr") {
radarr.gid = config.ids.gids.radarr; radarr.gid = config.ids.gids.radarr;
}; };
}; };