Testing assertions, think they work, but my server crashed...
This commit is contained in:
@@ -3,12 +3,12 @@
|
|||||||
lib,
|
lib,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
with lib; let
|
let
|
||||||
cfg = config.nixarr.jellyfin;
|
cfg = config.nixarr.jellyfin;
|
||||||
defaultPort = 8096;
|
defaultPort = 8096;
|
||||||
nixarr = config.nixarr;
|
nixarr = config.nixarr;
|
||||||
dnsServers = config.lib.vpn.dnsServers;
|
dnsServers = config.lib.vpn.dnsServers;
|
||||||
in {
|
in with lib; {
|
||||||
options.nixarr.jellyfin = {
|
options.nixarr.jellyfin = {
|
||||||
enable = mkEnableOption "the Jellyfin service.";
|
enable = mkEnableOption "the Jellyfin service.";
|
||||||
|
|
||||||
@@ -23,6 +23,7 @@ in {
|
|||||||
default = false;
|
default = false;
|
||||||
description = ''
|
description = ''
|
||||||
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
|
**Required options:** [`nixarr.vpn.enable`](/options.html#nixarr.vpn.enable)
|
||||||
|
**Conflicting options:** [`nixarr.jellyfin.expose.https.enable`](/options.html#nixarr.jellyfin.expose.https.enable)
|
||||||
|
|
||||||
Route Jellyfin traffic through the VPN.
|
Route Jellyfin traffic through the VPN.
|
||||||
'';
|
'';
|
||||||
@@ -105,11 +106,53 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config =
|
config =
|
||||||
# TODO: this doesn't work. I don't know why :(
|
|
||||||
#assert (!(cfg.vpn.enable && cfg.expose.enable)) || abort "vpn.enable not compatible with expose.enable.";
|
|
||||||
#assert (cfg.expose.enable -> (cfg.expose.domainName != null && cfg.expose.acmeMail != null)) || abort "Both expose.domain and expose.acmeMail needs to be set if expose.enable is set.";
|
|
||||||
mkIf cfg.enable
|
mkIf cfg.enable
|
||||||
{
|
{
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = cfg.vpn.enable && !nixarr.vpn.enable;
|
||||||
|
message = ''
|
||||||
|
The nixarr.jellyfin.vpn.enable option requires the
|
||||||
|
nixarr.vpn.enable option to be set, but it was not.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = !(cfg.vpn.enable && cfg.expose.https.enable);
|
||||||
|
message = ''
|
||||||
|
The nixarr.jellyfin.vpn.enable option conflicts with the
|
||||||
|
nixarr.jellyfin.expose.https.enable option. You cannot set both.
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = cfg.expose.https.enable -> (
|
||||||
|
cfg.expose.https.domainName != null &&
|
||||||
|
cfg.expose.https.acmeMail != null
|
||||||
|
);
|
||||||
|
message = ''
|
||||||
|
The nixarr.jellyfin.expose.https.enable option requires the
|
||||||
|
following options to be set, but one of them were not:
|
||||||
|
|
||||||
|
- nixarr.jellyfin.expose.domainName
|
||||||
|
- nixarr.jellyfin.expose.acmeMail
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = cfg.expose.vpn.enable -> (
|
||||||
|
!cfg.vpn.enable &&
|
||||||
|
cfg.expose.vpn.port != null &&
|
||||||
|
cfg.expose.vpn.accessibleFrom != null
|
||||||
|
);
|
||||||
|
message = ''
|
||||||
|
The nixarr.jellyfin.expose.vpn.enable option requires the
|
||||||
|
following options to be set, but one of them were not:
|
||||||
|
|
||||||
|
- nixarr.jellyfin.vpn.enable
|
||||||
|
- nixarr.jellyfin.expose.vpn.port
|
||||||
|
- nixarr.jellyfin.expose.vpn.accessibleFrom
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
systemd.tmpfiles.rules = [
|
systemd.tmpfiles.rules = [
|
||||||
"d '${cfg.stateDir}' 0700 streamer root - -"
|
"d '${cfg.stateDir}' 0700 streamer root - -"
|
||||||
];
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user