2020-04-24 23:36:52 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.services.jackett;
|
|
|
|
|
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.jackett = {
|
2024-09-19 14:19:46 +00:00
|
|
|
enable = lib.mkEnableOption "Jackett, API support for your favorite torrent trackers";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
port = lib.mkOption {
|
2024-07-27 06:49:29 +00:00
|
|
|
default = 9117;
|
2024-09-19 14:19:46 +00:00
|
|
|
type = lib.types.port;
|
2024-07-27 06:49:29 +00:00
|
|
|
description = ''
|
|
|
|
Port serving the web interface
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
dataDir = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "/var/lib/jackett/.config/Jackett";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "The directory where Jackett stores its data files.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
openFirewall = lib.mkOption {
|
|
|
|
type = lib.types.bool;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Open ports in the firewall for the Jackett web interface.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
user = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "jackett";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "User account under which Jackett runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
group = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
2020-04-24 23:36:52 +00:00
|
|
|
default = "jackett";
|
2024-04-21 15:54:59 +00:00
|
|
|
description = "Group under which Jackett runs.";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
package = lib.mkPackageOption pkgs "jackett" { };
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
config = lib.mkIf cfg.enable {
|
2020-04-24 23:36:52 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
|
|
|
systemd.services.jackett = {
|
|
|
|
description = "Jackett";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2024-07-27 06:49:29 +00:00
|
|
|
ExecStart = "${cfg.package}/bin/Jackett --NoUpdates --Port ${toString cfg.port} --DataFolder '${cfg.dataDir}'";
|
2020-04-24 23:36:52 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
networking.firewall = lib.mkIf cfg.openFirewall {
|
2024-07-27 06:49:29 +00:00
|
|
|
allowedTCPPorts = [ cfg.port ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
users.users = lib.mkIf (cfg.user == "jackett") {
|
2020-04-24 23:36:52 +00:00
|
|
|
jackett = {
|
|
|
|
group = cfg.group;
|
|
|
|
home = cfg.dataDir;
|
|
|
|
uid = config.ids.uids.jackett;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2024-09-19 14:19:46 +00:00
|
|
|
users.groups = lib.mkIf (cfg.group == "jackett") {
|
2020-04-24 23:36:52 +00:00
|
|
|
jackett.gid = config.ids.gids.jackett;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|