2018-07-20 21:56:59 +01:00
|
|
|
{ config, pkgs, lib, ... }:
|
2017-03-25 20:18:34 +00:00
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.jackett;
|
2019-02-19 19:45:00 +00:00
|
|
|
|
2017-03-25 20:18:34 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options = {
|
|
|
|
services.jackett = {
|
|
|
|
enable = mkEnableOption "Jackett";
|
2019-02-19 19:45:00 +00: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.";
|
|
|
|
};
|
2017-03-25 20:18:34 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd.services.jackett = {
|
|
|
|
description = "Jackett";
|
|
|
|
after = [ "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
preStart = ''
|
2019-02-19 19:45:00 +00:00
|
|
|
test -d ${cfg.dataDir} || {
|
|
|
|
echo "Creating jackett data directory in ${cfg.dataDir}"
|
|
|
|
mkdir -p ${cfg.dataDir}
|
2017-03-25 20:18:34 +00:00
|
|
|
}
|
2019-02-19 19:45:00 +00:00
|
|
|
chown -R ${cfg.user}:${cfg.group} ${cfg.dataDir}
|
|
|
|
chmod 0700 ${cfg.dataDir}
|
2017-03-25 20:18:34 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2019-02-19 19:45:00 +00:00
|
|
|
User = cfg.user;
|
|
|
|
Group = cfg.group;
|
2017-03-25 20:18:34 +00:00
|
|
|
PermissionsStartOnly = "true";
|
2019-02-19 19:45:00 +00:00
|
|
|
ExecStart = "${pkgs.jackett}/bin/Jackett --NoUpdates --DataFolder '${cfg.dataDir}'";
|
2017-03-25 20:18:34 +00:00
|
|
|
Restart = "on-failure";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2019-02-19 19:45:00 +00: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 20:18:34 +00:00
|
|
|
};
|
|
|
|
|
2019-02-19 19:45:00 +00:00
|
|
|
users.groups = mkIf (cfg.group == "jackett") {
|
|
|
|
jackett.gid = config.ids.gids.jackett;
|
|
|
|
};
|
2017-03-25 20:18:34 +00:00
|
|
|
};
|
|
|
|
}
|