blob: 8715a1272ddd5bdfeecc40d57b951b978218a468 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
{
config,
inputs,
lib,
libNginx,
this,
...
}:
with lib;
let
cfg = config.nixfiles.modules.piracy.sonarr;
port = 8989;
in
{
options.nixfiles.modules.piracy.sonarr = {
enable = mkEnableOption "Sonarr";
domain = mkOption {
description = "Domain name sans protocol scheme.";
type = with types; str;
default = "sonarr.${config.networking.domain}";
};
};
config = mkIf cfg.enable {
secrets.sonarr-api-key.file = "${inputs.self}/secrets/sonarr-api-key";
ark.directories = [ "/var/lib/sonarr" ];
nixfiles.modules = {
nginx = {
enable = true;
upstreams.sonarr.servers."127.0.0.1:${toString port}" = { };
virtualHosts.${cfg.domain} = {
locations."/".proxyPass = "http://sonarr";
extraConfig = libNginx.config.internalOnly;
};
};
piracy = {
enable = true;
jackett.enable = true;
};
};
services = {
sonarr = {
enable = true;
group = "piracy";
};
prometheus.exporters.exportarr-sonarr = {
enable = true;
url = "http://127.0.0.1";
port = port + 10000;
apiKeyFile = config.secrets.sonarr-api-key.path;
inherit (config.services.sonarr) user;
inherit (config.services.sonarr) group;
listenAddress = this.wireguard.ipv4.address;
environment.CONFIG = "/var/lib/sonarr/.config/Sonarr/config.xml";
};
};
systemd = {
tmpfiles.rules = with config.services.sonarr; [
"d /var/lib/sonarr/root 0755 ${user} ${group} - -"
];
services.sonarr.after = [
"flood.service"
"jackett.service"
"local-fs.target"
];
};
topology = with cfg; {
nodes.${this.hostname}.services.sonarr = {
info = domain;
details.listen.text = "127.0.0.1:${toString port}";
};
};
};
}
|