2021-01-31 22:32:30 +01:00
|
|
|
# The total autonomous media delivery system.
|
|
|
|
# Relevant link [1].
|
|
|
|
#
|
|
|
|
# [1]: https://youtu.be/I26Ql-uX6AM
|
|
|
|
{ config, lib, ... }:
|
|
|
|
let
|
|
|
|
cfg = config.my.services.pirate;
|
|
|
|
|
|
|
|
ports = {
|
|
|
|
bazarr = 6767;
|
2021-02-16 17:38:48 +01:00
|
|
|
lidarr = 8686;
|
2021-11-05 15:55:20 +01:00
|
|
|
radarr = 7878;
|
|
|
|
sonarr = 8989;
|
2021-01-31 22:32:30 +01:00
|
|
|
};
|
|
|
|
|
2023-09-03 12:22:02 +02:00
|
|
|
mkService = service: {
|
|
|
|
services.${service} = {
|
|
|
|
enable = true;
|
|
|
|
group = "media";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
mkRedirection = service: {
|
|
|
|
my.services.nginx.virtualHosts = [
|
|
|
|
{
|
|
|
|
subdomain = service;
|
|
|
|
port = ports.${service};
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
2021-01-31 22:32:30 +01:00
|
|
|
|
2023-09-03 12:22:02 +02:00
|
|
|
mkFullConfig = service: lib.mkMerge [
|
|
|
|
(mkService service)
|
|
|
|
(mkRedirection service)
|
|
|
|
];
|
2021-01-31 22:32:30 +01:00
|
|
|
in
|
|
|
|
{
|
|
|
|
options.my.services.pirate = {
|
|
|
|
enable = lib.mkEnableOption "Media automation";
|
|
|
|
};
|
|
|
|
|
2023-09-03 12:22:02 +02:00
|
|
|
config = lib.mkIf cfg.enable (lib.mkMerge [
|
|
|
|
{
|
|
|
|
# Set-up media group
|
|
|
|
users.groups.media = { };
|
|
|
|
}
|
|
|
|
# Bazarr for subtitles
|
|
|
|
(mkFullConfig "bazarr")
|
|
|
|
# Lidarr for music
|
|
|
|
(mkFullConfig "lidarr")
|
|
|
|
# Radarr for movies
|
|
|
|
(mkFullConfig "radarr")
|
|
|
|
# Sonarr for shows
|
|
|
|
(mkFullConfig "sonarr")
|
|
|
|
]);
|
2021-01-31 22:32:30 +01:00
|
|
|
}
|