nixos/radarr,lidarr,readarr,whisparr,prowlarr: add settings option (#384052)
This commit is contained in:
@@ -821,7 +821,6 @@
|
||||
./services/misc/klipper.nix
|
||||
./services/misc/languagetool.nix
|
||||
./services/misc/leaps.nix
|
||||
./services/misc/lidarr.nix
|
||||
./services/misc/lifecycled.nix
|
||||
./services/misc/llama-cpp.nix
|
||||
./services/misc/logkeys.nix
|
||||
@@ -861,12 +860,9 @@
|
||||
./services/misc/portunus.nix
|
||||
./services/misc/preload.nix
|
||||
./services/misc/private-gpt.nix
|
||||
./services/misc/prowlarr.nix
|
||||
./services/misc/pufferpanel.nix
|
||||
./services/misc/pykms.nix
|
||||
./services/misc/radarr.nix
|
||||
./services/misc/radicle.nix
|
||||
./services/misc/readarr.nix
|
||||
./services/misc/realmd.nix
|
||||
./services/misc/rebuilderd.nix
|
||||
./services/misc/recyclarr.nix
|
||||
@@ -878,13 +874,18 @@
|
||||
./services/misc/rshim.nix
|
||||
./services/misc/safeeyes.nix
|
||||
./services/misc/sdrplay.nix
|
||||
./services/misc/servarr/lidarr.nix
|
||||
./services/misc/servarr/prowlarr.nix
|
||||
./services/misc/servarr/radarr.nix
|
||||
./services/misc/servarr/readarr.nix
|
||||
./services/misc/servarr/sonarr.nix
|
||||
./services/misc/servarr/whisparr.nix
|
||||
./services/misc/serviio.nix
|
||||
./services/misc/sickbeard.nix
|
||||
./services/misc/signald.nix
|
||||
./services/misc/siproxd.nix
|
||||
./services/misc/snapper.nix
|
||||
./services/misc/soft-serve.nix
|
||||
./services/misc/sonarr.nix
|
||||
./services/misc/sourcehut
|
||||
./services/misc/spice-autorandr.nix
|
||||
./services/misc/spice-vdagentd.nix
|
||||
@@ -910,7 +911,6 @@
|
||||
./services/misc/wastebin.nix
|
||||
./services/misc/weechat.nix
|
||||
./services/misc/workout-tracker.nix
|
||||
./services/misc/whisparr.nix
|
||||
./services/misc/xmrig.nix
|
||||
./services/misc/ytdl-sub.nix
|
||||
./services/misc/zoneminder.nix
|
||||
|
||||
+8
-1
@@ -6,6 +6,7 @@
|
||||
}:
|
||||
let
|
||||
cfg = config.services.lidarr;
|
||||
servarr = import ./settings-options.nix { inherit lib pkgs; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@@ -28,6 +29,10 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
settings = servarr.mkServarrSettingsOptions "lidarr" 8686;
|
||||
|
||||
environmentFiles = servarr.mkServarrEnvironmentFiles "lidarr";
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "lidarr";
|
||||
@@ -56,18 +61,20 @@ in
|
||||
description = "Lidarr";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = servarr.mkServarrSettingsEnvVars "LIDARR" cfg.settings;
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
ExecStart = "${cfg.package}/bin/Lidarr -nobrowser -data='${cfg.dataDir}'";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ 8686 ];
|
||||
allowedTCPPorts = [ cfg.settings.server.port ];
|
||||
};
|
||||
|
||||
users.users = lib.mkIf (cfg.user == "lidarr") {
|
||||
+10
-3
@@ -6,7 +6,7 @@
|
||||
}:
|
||||
let
|
||||
cfg = config.services.prowlarr;
|
||||
|
||||
servarr = import ./settings-options.nix { inherit lib pkgs; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@@ -20,6 +20,10 @@ in
|
||||
default = false;
|
||||
description = "Open ports in the firewall for the Prowlarr web interface.";
|
||||
};
|
||||
|
||||
settings = servarr.mkServarrSettingsOptions "prowlarr" 9696;
|
||||
|
||||
environmentFiles = servarr.mkServarrEnvironmentFiles "prowlarr";
|
||||
};
|
||||
};
|
||||
|
||||
@@ -28,19 +32,22 @@ in
|
||||
description = "Prowlarr";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = servarr.mkServarrSettingsEnvVars "PROWLARR" cfg.settings // {
|
||||
HOME = "/var/empty";
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
DynamicUser = true;
|
||||
StateDirectory = "prowlarr";
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
ExecStart = "${lib.getExe cfg.package} -nobrowser -data=/var/lib/prowlarr";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
environment.HOME = "/var/empty";
|
||||
};
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ 9696 ];
|
||||
allowedTCPPorts = [ cfg.settings.server.port ];
|
||||
};
|
||||
};
|
||||
}
|
||||
+8
-2
@@ -6,7 +6,7 @@
|
||||
}:
|
||||
let
|
||||
cfg = config.services.radarr;
|
||||
|
||||
servarr = import ./settings-options.nix { inherit lib pkgs; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@@ -27,6 +27,10 @@ in
|
||||
description = "Open ports in the firewall for the Radarr web interface.";
|
||||
};
|
||||
|
||||
settings = servarr.mkServarrSettingsOptions "radarr" 7878;
|
||||
|
||||
environmentFiles = servarr.mkServarrEnvironmentFiles "radarr";
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "radarr";
|
||||
@@ -51,18 +55,20 @@ in
|
||||
description = "Radarr";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = servarr.mkServarrSettingsEnvVars "RADARR" cfg.settings;
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
ExecStart = "${cfg.package}/bin/Radarr -nobrowser -data='${cfg.dataDir}'";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ 7878 ];
|
||||
allowedTCPPorts = [ cfg.settings.server.port ];
|
||||
};
|
||||
|
||||
users.users = lib.mkIf (cfg.user == "radarr") {
|
||||
+8
-1
@@ -6,6 +6,7 @@
|
||||
}:
|
||||
let
|
||||
cfg = config.services.readarr;
|
||||
servarr = import ./settings-options.nix { inherit lib pkgs; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@@ -28,6 +29,10 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
settings = servarr.mkServarrSettingsOptions "readarr" 8787;
|
||||
|
||||
environmentFiles = servarr.mkServarrEnvironmentFiles "readarr";
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "readarr";
|
||||
@@ -56,18 +61,20 @@ in
|
||||
description = "Readarr";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = servarr.mkServarrSettingsEnvVars "READARR" cfg.settings;
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
ExecStart = "${cfg.package}/bin/Readarr -nobrowser -data='${cfg.dataDir}'";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ 8787 ];
|
||||
allowedTCPPorts = [ cfg.settings.server.port ];
|
||||
};
|
||||
|
||||
users.users = lib.mkIf (cfg.user == "readarr") {
|
||||
@@ -0,0 +1,88 @@
|
||||
{ lib, pkgs }:
|
||||
{
|
||||
mkServarrSettingsOptions =
|
||||
name: port:
|
||||
lib.mkOption {
|
||||
type = lib.types.submodule {
|
||||
freeformType = (pkgs.formats.ini { }).type;
|
||||
options = {
|
||||
update = {
|
||||
mechanism = lib.mkOption {
|
||||
type =
|
||||
with lib.types;
|
||||
nullOr (enum [
|
||||
"external"
|
||||
"builtIn"
|
||||
"script"
|
||||
]);
|
||||
description = "which update mechanism to use";
|
||||
default = "external";
|
||||
};
|
||||
automatically = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Automatically download and install updates.";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
server = {
|
||||
port = lib.mkOption {
|
||||
type = lib.types.int;
|
||||
description = "Port Number";
|
||||
default = port;
|
||||
};
|
||||
};
|
||||
log = {
|
||||
analyticsEnabled = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
description = "Send Anonymous Usage Data";
|
||||
default = false;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
example = lib.options.literalExpression ''
|
||||
{
|
||||
update.mechanism = "internal";
|
||||
server = {
|
||||
urlbase = "localhost";
|
||||
port = ${toString port};
|
||||
bindaddress = "*";
|
||||
};
|
||||
}
|
||||
'';
|
||||
default = { };
|
||||
description = ''
|
||||
Attribute set of arbitrary config options.
|
||||
Please consult the documentation at the [wiki](https://wiki.servarr.com/useful-tools#using-environment-variables-for-config).
|
||||
|
||||
WARNING: this configuration is stored in the world-readable Nix store!
|
||||
For secrets use [](#opt-services.${name}.environmentFiles).
|
||||
'';
|
||||
};
|
||||
|
||||
mkServarrEnvironmentFiles =
|
||||
name:
|
||||
lib.mkOption {
|
||||
type = lib.types.listOf lib.types.path;
|
||||
default = [ ];
|
||||
description = ''
|
||||
Environment file to pass secret configuration values.
|
||||
Each line must follow the `${lib.toUpper name}__SECTION__KEY=value` pattern.
|
||||
Please consult the documentation at the [wiki](https://wiki.servarr.com/useful-tools#using-environment-variables-for-config).
|
||||
'';
|
||||
};
|
||||
|
||||
mkServarrSettingsEnvVars =
|
||||
name: settings:
|
||||
lib.pipe settings [
|
||||
(lib.mapAttrsRecursive (
|
||||
path: value:
|
||||
lib.optionalAttrs (value != null) {
|
||||
name = lib.toUpper "${name}__${lib.concatStringsSep "__" path}";
|
||||
value = toString (if lib.isBool value then lib.boolToString value else value);
|
||||
}
|
||||
))
|
||||
(lib.collect (x: lib.isString x.name or false && lib.isString x.value or false))
|
||||
lib.listToAttrs
|
||||
];
|
||||
}
|
||||
+8
-2
@@ -7,6 +7,7 @@
|
||||
}:
|
||||
let
|
||||
cfg = config.services.sonarr;
|
||||
servarr = import ./settings-options.nix { inherit lib pkgs; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@@ -27,6 +28,10 @@ in
|
||||
'';
|
||||
};
|
||||
|
||||
environmentFiles = servarr.mkServarrEnvironmentFiles "sonarr";
|
||||
|
||||
settings = servarr.mkServarrSettingsOptions "sonarr" 8989;
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "sonarr";
|
||||
@@ -52,11 +57,12 @@ in
|
||||
description = "Sonarr";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
environment = servarr.mkServarrSettingsEnvVars "SONARR" cfg.settings;
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
ExecStart = utils.escapeSystemdExecArgs [
|
||||
(lib.getExe cfg.package)
|
||||
"-nobrowser"
|
||||
@@ -67,7 +73,7 @@ in
|
||||
};
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ 8989 ];
|
||||
allowedTCPPorts = [ cfg.settings.server.port ];
|
||||
};
|
||||
|
||||
users.users = lib.mkIf (cfg.user == "sonarr") {
|
||||
+10
-1
@@ -7,6 +7,7 @@
|
||||
|
||||
let
|
||||
cfg = config.services.whisparr;
|
||||
servarr = import ./settings-options.nix { inherit lib pkgs; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
@@ -27,6 +28,10 @@ in
|
||||
description = "Open ports in the firewall for the Whisparr web interface.";
|
||||
};
|
||||
|
||||
settings = servarr.mkServarrSettingsOptions "whisparr" 6969;
|
||||
|
||||
environmentFiles = servarr.mkServarrEnvironmentFiles "whisparr";
|
||||
|
||||
user = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "whisparr";
|
||||
@@ -48,17 +53,21 @@ in
|
||||
description = "Whisparr";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
environment = servarr.mkServarrSettingsEnvVars "WHISPARR" cfg.settings;
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
EnvironmentFile = cfg.environmentFiles;
|
||||
ExecStart = "${lib.getExe cfg.package} -nobrowser -data='${cfg.dataDir}'";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
networking.firewall = lib.mkIf cfg.openFirewall { allowedTCPPorts = [ 6969 ]; };
|
||||
networking.firewall = lib.mkIf cfg.openFirewall {
|
||||
allowedTCPPorts = [ cfg.settings.server.port ];
|
||||
};
|
||||
|
||||
users.users = lib.mkIf (cfg.user == "whisparr") {
|
||||
whisparr = {
|
||||
@@ -364,28 +364,10 @@ let
|
||||
apiKeyFile = pkgs.writeText "dummy-api-key" apikey;
|
||||
};
|
||||
metricProvider = {
|
||||
services.sonarr.enable = true;
|
||||
systemd.services.sonarr.serviceConfig.ExecStartPre =
|
||||
let
|
||||
sonarr_config = pkgs.writeText "config.xml" ''
|
||||
<Config>
|
||||
<LogLevel>info</LogLevel>
|
||||
<EnableSsl>False</EnableSsl>
|
||||
<Port>8989</Port>
|
||||
<SslPort>9898</SslPort>
|
||||
<UrlBase></UrlBase>
|
||||
<BindAddress>*</BindAddress>
|
||||
<ApiKey>${apikey}</ApiKey>
|
||||
<AuthenticationMethod>None</AuthenticationMethod>
|
||||
<UpdateMechanism>BuiltIn</UpdateMechanism>
|
||||
<Branch>main</Branch>
|
||||
<InstanceName>Sonarr</InstanceName>
|
||||
</Config>
|
||||
'';
|
||||
in
|
||||
[
|
||||
''${pkgs.coreutils}/bin/install -D -m 777 ${sonarr_config} -T /var/lib/sonarr/.config/NzbDrone/config.xml''
|
||||
];
|
||||
services.sonarr = {
|
||||
enable = true;
|
||||
environmentFiles = [(pkgs.writeText "sonarr-env" "SONARR__AUTH__APIKEY=${apikey}")];
|
||||
};
|
||||
};
|
||||
exporterTest = ''
|
||||
wait_for_unit("sonarr.service")
|
||||
|
||||
Reference in New Issue
Block a user