modules: services: pirate: refactor
This will make adding fail2ban jails easier.
This commit is contained in:
parent
adc4ce9d8a
commit
14bf03e5fd
|
@ -13,26 +13,44 @@ let
|
||||||
sonarr = 8989;
|
sonarr = 8989;
|
||||||
};
|
};
|
||||||
|
|
||||||
managers = with lib.attrsets;
|
mkService = service: {
|
||||||
(mapAttrs
|
services.${service} = {
|
||||||
(_: _: {
|
|
||||||
enable = true;
|
enable = true;
|
||||||
group = "media";
|
group = "media";
|
||||||
})
|
};
|
||||||
ports);
|
};
|
||||||
|
|
||||||
redirections = lib.flip lib.mapAttrsToList ports
|
mkRedirection = service: {
|
||||||
(subdomain: port: { inherit subdomain port; });
|
my.services.nginx.virtualHosts = [
|
||||||
|
{
|
||||||
|
subdomain = service;
|
||||||
|
port = ports.${service};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
mkFullConfig = service: lib.mkMerge [
|
||||||
|
(mkService service)
|
||||||
|
(mkRedirection service)
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.my.services.pirate = {
|
options.my.services.pirate = {
|
||||||
enable = lib.mkEnableOption "Media automation";
|
enable = lib.mkEnableOption "Media automation";
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
||||||
services = managers;
|
{
|
||||||
my.services.nginx.virtualHosts = redirections;
|
|
||||||
# Set-up media group
|
# Set-up media group
|
||||||
users.groups.media = { };
|
users.groups.media = { };
|
||||||
};
|
}
|
||||||
|
# Bazarr for subtitles
|
||||||
|
(mkFullConfig "bazarr")
|
||||||
|
# Lidarr for music
|
||||||
|
(mkFullConfig "lidarr")
|
||||||
|
# Radarr for movies
|
||||||
|
(mkFullConfig "radarr")
|
||||||
|
# Sonarr for shows
|
||||||
|
(mkFullConfig "sonarr")
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue