From 6038d0df60924dbb1b92a4b4bdd3a41e7cb839c6 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Mon, 1 Feb 2021 16:25:34 +0100 Subject: [PATCH] services: add sabnzbd Its configuration isn't declarative :-(. Notably, the port needs to be changed from '8080' to '9090' in its configuration file (at '/var/lib/sabnzbd/'). --- configuration.nix | 2 ++ services/default.nix | 1 + services/media.nix | 2 +- services/sabnzbd.nix | 28 ++++++++++++++++++++++++++++ 4 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 services/sabnzbd.nix diff --git a/configuration.nix b/configuration.nix index 618af96..e71ea65 100644 --- a/configuration.nix +++ b/configuration.nix @@ -80,6 +80,8 @@ matrix.enable = true; # The whole *arr software suite pirate.enable = true; + # Usenet client + sabnzbd.enable = true; # Torrent client and webui transmission = { enable = true; diff --git a/services/default.nix b/services/default.nix index 7edb7a7..75af859 100644 --- a/services/default.nix +++ b/services/default.nix @@ -8,6 +8,7 @@ ./media.nix ./nginx.nix ./pirate.nix + ./sabnzbd.nix ./transmission.nix ]; } diff --git a/services/media.nix b/services/media.nix index 2b5da27..fc6a8b1 100644 --- a/services/media.nix +++ b/services/media.nix @@ -3,7 +3,7 @@ { config, lib, ... }: let needed = with config.my.services; - jellyfin.enable || pirate.enable || transmission.enable; + jellyfin.enable || pirate.enable || sabnzbd.enable || transmission.enable; in { config.users.groups.media = lib.mkIf needed { }; diff --git a/services/sabnzbd.nix b/services/sabnzbd.nix new file mode 100644 index 0000000..d1dfa48 --- /dev/null +++ b/services/sabnzbd.nix @@ -0,0 +1,28 @@ +# Usenet binary client. +{ config, lib, ... }: +let + cfg = config.my.services.sabnzbd; + + domain = config.networking.domain; + sabnzbdDomain = "sabnzbd.${domain}"; + port = 9090; # NOTE: not declaratively set... +in +{ + options.my.services.sabnzbd = with lib; { + enable = mkEnableOption "SABnzbd binary news reader"; + }; + + config = lib.mkIf cfg.enable { + services.sabnzbd = { + enable = true; + group = "media"; + }; + + services.nginx.virtualHosts."${sabnzbdDomain}" = { + forceSSL = true; + useACMEHost = domain; + + locations."/".proxyPass = "http://localhost:${toString port}"; + }; + }; +}