modules: services: use new nginx wrapper
All checks were successful
continuous-integration/drone/push Build is passing

And when not possible, document why.

Note for the future: there is some repetition in some modules to
configure the correct value of the subdomain, which I happen to know
will line up correctly thanks to the nginx wrapper. A good way to
refactor this in the future would involve avoiding this repetition,
allowing use to query the correct domain in some way...
This commit is contained in:
Bruno BELANYI 2021-08-24 23:05:10 +02:00
parent 81e12969eb
commit 7032ddef37
19 changed files with 187 additions and 254 deletions

View file

@ -5,7 +5,6 @@
{ config, lib, ... }:
let
cfg = config.my.services.pirate;
domain = config.networking.domain;
ports = {
sonarr = 8989;
@ -22,15 +21,8 @@ let
})
ports);
redirections = with lib.attrsets;
(mapAttrs'
(service: port: nameValuePair "${service}.${domain}" {
forceSSL = true;
useACMEHost = domain;
locations."/".proxyPass = "http://127.0.0.1:${builtins.toString port}/";
})
ports);
redirections = lib.flip lib.mapAttrsToList ports
(subdomain: port: { inherit subdomain port; });
in
{
options.my.services.pirate = {
@ -38,6 +30,7 @@ in
};
config = lib.mkIf cfg.enable {
services = managers // { nginx.virtualHosts = redirections; };
services = managers;
my.services.nginx.virtualHosts = redirections;
};
}