fix(mediabox): mediatomb

This commit is contained in:
arcnmx 2024-02-23 10:37:53 -08:00
parent 1d038633ce
commit ef5306904c
9 changed files with 61 additions and 17 deletions

View file

@ -5,8 +5,9 @@
}: let
inherit (lib.options) mkOption;
inherit (lib.modules) mkIf mkDefault mkOptionDefault;
inherit (config.services) nginx;
cfg = config.services.plex;
access = config.services.nginx.access.plex;
access = nginx.access.plex;
in {
options.services.nginx.access.plex = with lib.types; {
url = mkOption {
@ -20,10 +21,14 @@ in {
type = str;
default = "plex.local.${config.networking.domain}";
};
externalPort = mkOption {
type = nullOr port;
default = null;
};
};
config.services.nginx = {
access.plex = mkIf cfg.enable {
url = mkOptionDefault "http://localhost:32400";
url = mkOptionDefault "http://localhost:${toString cfg.port}";
};
virtualHosts = let
extraConfig = ''
@ -62,6 +67,19 @@ in {
kTLS = mkDefault true;
inherit extraConfig;
};
plex-external = mkIf (access.externalPort != null) {
serverName = mkDefault access.domain;
default = mkDefault true;
listen = map (addr: {
inherit addr;
port = access.externalPort;
}) nginx.defaultListenAddresses;
locations."/" = location;
inherit extraConfig;
};
};
};
config.networking.firewall.allowedTCPPorts = mkIf (access.externalPort != null) [
access.externalPort
];
}

View file

@ -3,8 +3,9 @@
lib,
...
}: let
inherit (lib.modules) mkIf mkAfter mkDefault;
inherit (lib.modules) mkIf mkMerge mkAfter mkDefault;
inherit (lib.strings) hasPrefix removePrefix;
inherit (config.services) mediatomb;
cfg = config.services.deluge;
in {
sops.secrets.deluge-auth = {
@ -57,7 +58,12 @@ in {
download
(mkIf (completedDir != null && !hasCompletedSubdir) completed)
]);
users.users.deluge = mkIf cfg.enable {
extraGroups = [ "kyuuto" ];
};
users.users = mkIf cfg.enable (mkMerge [
{
deluge.extraGroups = [ "kyuuto" ];
}
(mkIf mediatomb.enable {
${mediatomb.user}.extraGroups = [ cfg.group ];
})
]);
}

View file

@ -1,12 +1,17 @@
{
config,
lib,
...
}: let
inherit (lib.modules) mkDefault;
inherit (lib.modules) mkDefault mkIf;
cfg = config.services.mediatomb;
in {
config.services.mediatomb = {
enable = mkDefault true;
port = mkDefault 4152;
uuid = mkDefault "082fd344-bf69-5b72-a68f-a5a4d88e76b2";
};
config.users.users = mkIf cfg.enable {
${cfg.user}.extraGroups = [ "kyuuto" ];
};
}

View file

@ -21,7 +21,7 @@ in {
# * 32410, 32412, 32413, 32414 - GDM Network Discovery
networking.firewall.interfaces.local = {
allowedTCPPorts = [32400 8324 32469];
allowedTCPPorts = [cfg.port 8324 32469];
allowedUDPPorts = [1900 32410 32412 32413 32414];
};
}