services: add pirate

The whole suite of *-arr media managers.
This commit is contained in:
Bruno BELANYI 2021-01-31 22:32:30 +01:00
parent 9446651944
commit 680d82bc3b
4 changed files with 46 additions and 1 deletions

View file

@ -78,6 +78,8 @@
jellyfin.enable = true; jellyfin.enable = true;
# Matrix backend and Element chat front-end # Matrix backend and Element chat front-end
matrix.enable = true; matrix.enable = true;
# The whole *arr software suite
pirate.enable = true;
}; };
programs.gnupg.agent = { programs.gnupg.agent = {

View file

@ -7,5 +7,6 @@
./matrix.nix ./matrix.nix
./media.nix ./media.nix
./nginx.nix ./nginx.nix
./pirate.nix
]; ];
} }

View file

@ -3,7 +3,7 @@
{ config, lib, ... }: { config, lib, ... }:
let let
needed = with config.my.services; needed = with config.my.services;
jellyfin.enable; jellyfin.enable || pirate.enable;
in in
{ {
config.users.groups.media = lib.mkIf needed { }; config.users.groups.media = lib.mkIf needed { };

42
services/pirate.nix Normal file
View file

@ -0,0 +1,42 @@
# The total autonomous media delivery system.
# Relevant link [1].
#
# [1]: https://youtu.be/I26Ql-uX6AM
{ config, lib, ... }:
let
cfg = config.my.services.pirate;
domain = config.networking.domain;
ports = {
sonarr = 8989;
radarr = 7878;
bazarr = 6767;
};
managers = with lib.attrsets;
(mapAttrs
(_: _: {
enable = true;
group = "media";
})
ports);
redirections = with lib.attrsets;
(mapAttrs'
(service: port: nameValuePair "${service}.${domain}" {
forceSSL = true;
useACMEHost = "${domain}";
locations."/".proxyPass = "http://localhost:${builtins.toString port}/";
})
ports);
in
{
options.my.services.pirate = {
enable = lib.mkEnableOption "Media automation";
};
config = lib.mkIf cfg.enable {
services = managers // { nginx.virtualHosts = redirections; };
};
}