2018-07-20 22:56:59 +02:00
|
|
|
{ config, pkgs, lib, ... }:
|
2017-03-25 21:18:34 +01:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.jackett;
|
2019-02-19 20:45:00 +01:00
|
|
|
|
2017-03-25 21:18:34 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.jackett = {
|
|
|
|
enable = mkEnableOption "Jackett";
|
2019-02-19 20:45:00 +01:00
|
|
|
|
|
|
|
dataDir = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "/var/lib/jackett/.config/Jackett";
|
|
|
|
description = "The directory where Jackett stores its data files.";
|
|
|
|
};
|
|
|
|
|
|
|
|
openFirewall = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = "Open ports in the firewall for the Jackett web interface.";
|
|
|
|
};
|
|
|
|
|
|
|
|
user = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "jackett";
|
|
|
|
description = "User account under which Jackett runs.";
|
|
|
|
};
|
|
|
|
|
|
|
|
group = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
default = "jackett";
|
|
|
|
description = "Group under which Jackett runs.";
|
|
|
|
};
|
2019-07-07 13:23:01 +02:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.jackett;
|
|
|
|
defaultText = "pkgs.jackett";
|
|
|
|
description = "Jackett package to use.";
|
|
|
|
};
|
2017-03-25 21:18:34 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-02-23 23:00:28 +01:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d '${cfg.dataDir}' 0700 ${cfg.user} ${cfg.group} - -"
|
|
|
|
];
|
|
|
|
|
2017-03-25 21:18:34 +01:00
|
|
|
systemd.services.jackett = {
|
|
|
|
description = "Jackett";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2019-02-19 20:45:00 +01:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2019-07-07 13:23:01 +02:00
|
|
|
ExecStart = "${cfg.package}/bin/Jackett --NoUpdates --DataFolder '${cfg.dataDir}'";
|
2017-03-25 21:18:34 +01:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-02-19 20:45:00 +01:00
|
|
|
networking.firewall = mkIf cfg.openFirewall {
|
|
|
|
allowedTCPPorts = [ 9117 ];
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users = mkIf (cfg.user == "jackett") {
|
|
|
|
jackett = {
|
|
|
|
group = cfg.group;
|
|
|
|
home = cfg.dataDir;
|
|
|
|
uid = config.ids.uids.jackett;
|
|
|
|
};
|
2017-03-25 21:18:34 +01:00
|
|
|
};
|
|
|
|
|
2019-02-19 20:45:00 +01:00
|
|
|
users.groups = mkIf (cfg.group == "jackett") {
|
|
|
|
jackett.gid = config.ids.gids.jackett;
|
|
|
|
};
|
2017-03-25 21:18:34 +01:00
|
|
|
};
|
|
|
|
}
|