add unpackerr

This commit is contained in:
Vivian 2022-10-15 15:38:47 +02:00
parent 919ab390de
commit 4dbd3c6f89
3 changed files with 99 additions and 52 deletions

View file

@ -57,7 +57,8 @@ let
''; '';
}; };
}; };
in { in
{
options.services.unpackerr = { options.services.unpackerr = {
enable = mkEnableOption "unpackerr"; enable = mkEnableOption "unpackerr";
@ -224,6 +225,16 @@ in {
''; '';
example = { UN_WEBHOOK_0_URL = "http://example.com"; }; example = { UN_WEBHOOK_0_URL = "http://example.com"; };
}; };
environmentFile = mkOption {
type = types.nullOr types.path;
default = null;
description = lib.mdDoc ''
Environment file (see `systemd.exec(5)`
"EnvironmentFile=" section for the syntax) to define variables for unpackerr.
This option can be used to safely include secret keys into the unpackerr configuration.
'';
};
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable {
@ -247,7 +258,8 @@ in {
after = [ "network.target" ]; after = [ "network.target" ];
description = "unpackerr system service"; description = "unpackerr system service";
# Filter out all unset variables else unpackerr complains # Filter out all unset variables else unpackerr complains
environment = filterAttrs (n: v: stringLength v > 0) { environment = filterAttrs (n: v: stringLength v > 0)
{
# General options # General options
UN_DEBUG = "${toString cfg.debug}"; UN_DEBUG = "${toString cfg.debug}";
UN_INTERVAL = "${cfg.interval}"; UN_INTERVAL = "${cfg.interval}";
@ -308,6 +320,8 @@ in {
Type = "simple"; Type = "simple";
Restart = "on-failure"; Restart = "on-failure";
ExecStart = "${cfg.package}/bin/unpackerr"; ExecStart = "${cfg.package}/bin/unpackerr";
} // optionalAttrs (cfg.environmentFile != null) {
EnvironmentFile = cfg.environmentFile;
}; };
}; };
}; };

View file

@ -77,7 +77,6 @@
hostname = "unpackerr"; hostname = "unpackerr";
ip = "192.168.0.116"; ip = "192.168.0.116";
mac = "06:8a:8e:3e:43:45"; mac = "06:8a:8e:3e:43:45";
nix = false;
} }
{ {
hostname = "thelounge"; hostname = "thelounge";

View file

@ -0,0 +1,34 @@
{ config, pkgs, ... }:
let vs = config.vault-secrets.secrets;
in
{
networking.interfaces.eth0.useDHCP = true;
fileSystems."/mnt/storage" = {
device = "storage:/mnt/storage";
fsType = "nfs";
};
system.stateVersion = "21.11";
vault-secrets.secrets.unpackerr = { };
services.unpackerr = {
enable = true;
debug = true;
environmentFile = "${vs.unpackerr}/environment";
sonarr = {
url = "http://sonarr2:8989/";
paths = "/mnt/storage/torrents/r/TV";
};
radarr = {
url = "http://radarr2:7878/";
paths = "/mnt/storage/torrents/r/Movie";
};
lidarr = {
url = "http://lidarr:8686/";
paths = "/mnt/storage/torrents/r/Music";
};
};
}