nixos/services.lidarr: remove with lib;

This commit is contained in:
Felix Buehler 2024-08-24 22:05:47 +02:00
parent 4e1b387f24
commit d562492115

View File

@ -1,41 +1,38 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.services.lidarr;
in
{
options = {
services.lidarr = {
enable = mkEnableOption "Lidarr, a Usenet/BitTorrent music downloader";
enable = lib.mkEnableOption "Lidarr, a Usenet/BitTorrent music downloader";
dataDir = mkOption {
type = types.str;
dataDir = lib.mkOption {
type = lib.types.str;
default = "/var/lib/lidarr/.config/Lidarr";
description = "The directory where Lidarr stores its data files.";
};
package = mkPackageOption pkgs "lidarr" { };
package = lib.mkPackageOption pkgs "lidarr" { };
openFirewall = mkOption {
type = types.bool;
openFirewall = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Open ports in the firewall for Lidarr
'';
};
user = mkOption {
type = types.str;
user = lib.mkOption {
type = lib.types.str;
default = "lidarr";
description = ''
User account under which Lidarr runs.
'';
};
group = mkOption {
type = types.str;
group = lib.mkOption {
type = lib.types.str;
default = "lidarr";
description = ''
Group under which Lidarr runs.
@ -44,7 +41,7 @@ in
};
};
config = mkIf cfg.enable {
config = lib.mkIf cfg.enable {
systemd.tmpfiles.settings."10-lidarr".${cfg.dataDir}.d = {
inherit (cfg) user group;
mode = "0700";
@ -64,11 +61,11 @@ in
};
};
networking.firewall = mkIf cfg.openFirewall {
networking.firewall = lib.mkIf cfg.openFirewall {
allowedTCPPorts = [ 8686 ];
};
users.users = mkIf (cfg.user == "lidarr") {
users.users = lib.mkIf (cfg.user == "lidarr") {
lidarr = {
group = cfg.group;
home = "/var/lib/lidarr";
@ -76,7 +73,7 @@ in
};
};
users.groups = mkIf (cfg.group == "lidarr") {
users.groups = lib.mkIf (cfg.group == "lidarr") {
lidarr = {
gid = config.ids.gids.lidarr;
};