Repository navigation
Expand file tree
/
Copy pathconfiguration.nix
More file actions
191 lines (172 loc) · 5.4 KB
/
Copy pathconfiguration.nix
File metadata and controls
191 lines (172 loc) · 5.4 KB
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
{
config,
lib,
pkgs,
...
}:
let
cfg = config.homelab;
in
{
imports = [
./media-group.nix
./caddy.nix
./ddns.nix
./vpn.nix
./migrate.nix
./services/jellyfin.nix
./services/sonarr.nix
./services/radarr.nix
./services/deluge.nix
./services/prowlarr.nix
./services/readarr.nix
./services/flaresolverr.nix
./services/calibre.nix
];
options.homelab = {
domain = lib.mkOption {
type = lib.types.str;
default = "dosa.geooot.com";
description = "Base domain for homelab virtual hosts.";
};
publicDomain = lib.mkOption {
type = lib.types.str;
default = "geooot.com";
description = "Base domain for publicly exposed homelab virtual hosts.";
};
mediaDir = lib.mkOption {
type = lib.types.str;
default = "/dosa/media";
description = "Directory containing media libraries (movies, tv, anime, books, downloads).";
};
mediaGroup = lib.mkOption {
type = lib.types.str;
default = "media";
description = "Shared group for all homelab service users and media files.";
};
migrateSourceDir = lib.mkOption {
type = lib.types.str;
default = "/mnt/dfw/config";
description = "Source directory containing old docker configs to migrate via homelab-migrate.";
};
acmeEmail = lib.mkOption {
type = lib.types.str;
default = "me@geooot.com";
description = "Email for LetsEncrypt ACME account.";
};
cloudflareTokenFile = lib.mkOption {
type = lib.types.str;
default = "/var/lib/caddy-secrets/cloudflare-token";
description = ''
systemd EnvironmentFile containing a line
`CLOUDFLARE_API_TOKEN=<token>` with Cloudflare API access
(Zone:DNS:Edit on the base domain). Used by Caddy for DNS-01
ACME challenges. Create this file before starting Caddy.
'';
};
caddyPluginHash = lib.mkOption {
type = lib.types.str;
default = "sha256-WWMdpXe+uCE1Lh7Q+jDvCUi++B+Gimy3YR5x+aRG+Yc=";
description = "Vendor hash for caddy built with the cloudflare DNS + IP source plugins.";
};
calibreAdminHash = lib.mkOption {
type = lib.types.str;
default = "$2y$05$gdP3W6zsO0Ld8zoCfaSGOONZBJdPaRQ6tCUluUXrZExjTGTOCdCeW";
description = "bcrypt hash for the basic-auth protected calibre admin vhost.";
};
vpn = {
enable = lib.mkEnableOption "Surfshark WireGuard tunnel in an isolated network namespace";
bindDeluge = lib.mkOption {
type = lib.types.bool;
default = false;
description = ''
Run deluge inside the surfshark network namespace so all torrent
traffic is forced through the VPN (kill switch). When enabling this,
update the deluge download client host in Sonarr/Radarr/Readarr from
`localhost` to `10.99.0.2` (the veth address of the namespace).
Requires homelab.vpn.enable.
'';
};
privateKeyFile = lib.mkOption {
type = lib.types.str;
default = "/var/lib/surfshark-secrets/private-key";
description = "Path to a file containing the Surfshark WireGuard private key.";
};
endpoint = lib.mkOption {
type = lib.types.str;
default = "";
description = "Surfshark WireGuard endpoint (host:port).";
};
publicKey = lib.mkOption {
type = lib.types.str;
default = "";
description = "Surfshark WireGuard peer public key.";
};
address = lib.mkOption {
type = lib.types.str;
default = "";
description = "WireGuard interface address assigned by Surfshark.";
};
dns = lib.mkOption {
type = lib.types.listOf lib.types.str;
default = [ ];
description = "DNS servers used inside the surfshark namespace.";
};
};
services = {
jellyfin.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Jellyfin.";
};
sonarr.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Sonarr.";
};
radarr.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Radarr.";
};
deluge.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Deluge.";
};
prowlarr.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Prowlarr.";
};
readarr.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Readarr.";
};
flaresolverr.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable FlareSolverr.";
};
calibre.enable = lib.mkOption {
type = lib.types.bool;
default = true;
description = "Enable Calibre server and web.";
};
};
};
config = {
assertions = [
{
assertion =
cfg.vpn.enable -> cfg.vpn.publicKey != "" && cfg.vpn.endpoint != "" && cfg.vpn.address != "";
message = "homelab.vpn.{publicKey,endpoint,address} must be set when homelab.vpn.enable is true.";
}
{
assertion = cfg.vpn.bindDeluge -> cfg.vpn.enable;
message = "homelab.vpn.bindDeluge requires homelab.vpn.enable.";
}
];
};
}