nixos/jackett: add configurable port

This commit is contained in:
Mateusz Galazyn 2024-07-25 20:20:21 +02:00
parent 9962bb4f68
commit a0906cbd16
No known key found for this signature in database
2 changed files with 19 additions and 7 deletions

View File

@ -11,6 +11,14 @@ in
services.jackett = {
enable = mkEnableOption "Jackett, API support for your favorite torrent trackers";
port = mkOption {
default = 9117;
type = types.port;
description = ''
Port serving the web interface
'';
};
dataDir = mkOption {
type = types.str;
default = "/var/lib/jackett/.config/Jackett";
@ -53,13 +61,13 @@ in
Type = "simple";
User = cfg.user;
Group = cfg.group;
ExecStart = "${cfg.package}/bin/Jackett --NoUpdates --DataFolder '${cfg.dataDir}'";
ExecStart = "${cfg.package}/bin/Jackett --NoUpdates --Port ${toString cfg.port} --DataFolder '${cfg.dataDir}'";
Restart = "on-failure";
};
};
networking.firewall = mkIf cfg.openFirewall {
allowedTCPPorts = [ 9117 ];
allowedTCPPorts = [ cfg.port ];
};
users.users = mkIf (cfg.user == "jackett") {

View File

@ -1,17 +1,21 @@
import ./make-test-python.nix ({ lib, ... }:
{
let
jackettPort = 9117;
in {
name = "jackett";
meta.maintainers = with lib.maintainers; [ etu ];
nodes.machine =
{ pkgs, ... }:
{ services.jackett.enable = true; };
{ pkgs, ... }: {
services.jackett.enable = true;
services.jackett.port = jackettPort;
};
testScript = ''
machine.start()
machine.wait_for_unit("jackett.service")
machine.wait_for_open_port(9117)
machine.succeed("curl --fail http://localhost:9117/")
machine.wait_for_open_port(${toString jackettPort})
machine.succeed("curl --fail http://localhost:${toString jackettPort}/")
'';
})