Working navidrome

This commit is contained in:
Natsu Kagami 2022-06-11 15:53:34 -04:00
parent dff7e69dab
commit cc57af4546
Signed by: nki
GPG key ID: 7306B3D3C3AD6E51
3 changed files with 33 additions and 5 deletions

View file

@ -38,6 +38,11 @@ let
default = null;
description = "The filter syntax for the router. Overrides `host` and `path` if provided";
};
localHost = mkOption {
type = types.nullOr types.str;
description = "The local host of the service. Must be an IP if protocol is TCP. Default to localhost/127.0.0.1";
default = null;
};
port = mkOption {
type = types.port;
description = "The port that the service is listening on";
@ -91,9 +96,18 @@ let
else abort "Cannot have middlewares on tcp routers"
);
services."${name}-service".loadBalancer.servers = [
(if host.protocol == "http" then
{ url = "http://localhost:${toString host.port}"; }
else { address = "127.0.0.1:${toString host.port}"; }
(
let
localhost =
if isNull host.localHost then
(
if host.protocol == "http" then "localhost"
else "127.0.0.1"
) else host.localHost;
in
if host.protocol == "http" then
{ url = "http://${localhost}:${toString host.port}"; }
else { address = "${localhost}:${toString host.port}"; }
)
];
} // (if (host.middlewares != [ ]) then {