1
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-06-19 07:59:24 +03:00
nixpkgs/nixos/modules/services/misc/readarr.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

87 lines
1.9 KiB
Nix
Raw Normal View History

2023-03-12 20:54:23 +01:00
{
config,
pkgs,
lib,
...
}:
let
cfg = config.services.readarr;
in
{
options = {
services.readarr = {
enable = lib.mkEnableOption "Readarr, a Usenet/BitTorrent ebook downloader";
2023-03-12 20:54:23 +01:00
dataDir = lib.mkOption {
type = lib.types.str;
2023-03-12 20:54:23 +01:00
default = "/var/lib/readarr/";
description = "The directory where Readarr stores its data files.";
};
package = lib.mkPackageOption pkgs "readarr" { };
2023-03-12 20:54:23 +01:00
openFirewall = lib.mkOption {
type = lib.types.bool;
2023-03-12 20:54:23 +01:00
default = false;
description = ''
Open ports in the firewall for Readarr
'';
};
user = lib.mkOption {
type = lib.types.str;
2023-03-12 20:54:23 +01:00
default = "readarr";
description = ''
User account under which Readarr runs.
'';
};
group = lib.mkOption {
type = lib.types.str;
2023-03-12 20:54:23 +01:00
default = "readarr";
description = ''
Group under which Readarr runs.
'';
};
};
};
config = lib.mkIf cfg.enable {
2024-01-11 22:10:18 +01:00
systemd.tmpfiles.settings."10-readarr".${cfg.dataDir}.d = {
inherit (cfg) user group;
mode = "0700";
};
2023-03-12 20:54:23 +01:00
systemd.services.readarr = {
description = "Readarr";
after = [ "network.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
User = cfg.user;
Group = cfg.group;
ExecStart = "${cfg.package}/bin/Readarr -nobrowser -data='${cfg.dataDir}'";
Restart = "on-failure";
};
};
networking.firewall = lib.mkIf cfg.openFirewall {
2023-03-12 20:54:23 +01:00
allowedTCPPorts = [ 8787 ];
};
users.users = lib.mkIf (cfg.user == "readarr") {
2023-03-12 20:54:23 +01:00
readarr = {
description = "Readarr service";
home = cfg.dataDir;
group = cfg.group;
isSystemUser = true;
};
};
users.groups = lib.mkIf (cfg.group == "readarr") {
2023-03-12 20:54:23 +01:00
readarr = { };
};
};
}