From e29adcda0366e8c140a09a78e7381793084068f4 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Wed, 3 Feb 2021 22:07:11 +0100 Subject: [PATCH] services: add indexers Includes both Jackett and NZBHydra2. --- configuration.nix | 5 +++++ services/default.nix | 1 + services/indexers.nix | 44 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 100644 services/indexers.nix diff --git a/configuration.nix b/configuration.nix index 48c2605..9432c3a 100644 --- a/configuration.nix +++ b/configuration.nix @@ -86,6 +86,11 @@ my.services = { # Gitea forge gitea.enable = true; + # Meta-indexers + indexers = { + jackett.enable = true; + nzbhydra.enable = true; + }; # Jellyfin media server jellyfin.enable = true; # Matrix backend and Element chat front-end diff --git a/services/default.nix b/services/default.nix index eb63bc5..d9ab820 100644 --- a/services/default.nix +++ b/services/default.nix @@ -3,6 +3,7 @@ { imports = [ ./gitea.nix + ./indexers.nix ./jellyfin.nix ./matrix.nix ./media.nix diff --git a/services/indexers.nix b/services/indexers.nix new file mode 100644 index 0000000..eb304b0 --- /dev/null +++ b/services/indexers.nix @@ -0,0 +1,44 @@ +# Torrent and usenet meta-indexers +{ config, lib, ... }: +let + cfg = config.my.services.indexers; + + domain = config.networking.domain; + jackettDomain = "jackett.${config.networking.domain}"; + nzbhydraDomain = "nzbhydra.${config.networking.domain}"; + + jackettPort = 9117; + nzbhydraPort = 5076; +in +{ + options.my.services.indexers = with lib; { + jackett.enable = mkEnableOption "Jackett torrent meta-indexer"; + nzbhydra.enable = mkEnableOption "NZBHydra2 torrent meta-indexer"; + }; + + config = { + services.jackett = lib.mkIf cfg.jackett.enable { + enable = true; + }; + + services.nginx.virtualHosts."${jackettDomain}" = + lib.mkIf cfg.jackett.enable { + forceSSL = true; + useACMEHost = "${domain}"; + + locations."/".proxyPass = "http://localhost:${toString jackettPort}/"; + }; + + services.nzbhydra2 = lib.mkIf cfg.nzbhydra.enable { + enable = true; + }; + + services.nginx.virtualHosts."${nzbhydraDomain}" = + lib.mkIf cfg.nzbhydra.enable { + forceSSL = true; + useACMEHost = "${domain}"; + + locations."/".proxyPass = "http://localhost:${toString nzbhydraPort}/"; + }; + }; +}