infrastructure/nixos/access/zigbee2mqtt.nix
2024-03-21 12:40:50 -07:00

35 lines
862 B
Nix

{
config,
lib,
...
}: let
inherit (lib.modules) mkIf mkDefault;
inherit (config.services) nginx zigbee2mqtt;
name.shortServer = mkDefault "z2m";
in {
config.services.nginx = {
virtualHosts = {
zigbee2mqtt = {
locations."/" = {
proxy.websocket.enable = true;
proxyPass = mkIf zigbee2mqtt.enable (
mkDefault "http://localhost:${toString zigbee2mqtt.settings.frontend.port}"
);
};
inherit name;
vouch.enable = true;
};
zigbee2mqtt'local = {
inherit name;
ssl.cert.copyFromVhost = "zigbee2mqtt";
locations."/" = {
proxy.websocket.enable = true;
proxyPass = mkDefault (
nginx.virtualHosts.zigbee2mqtt.locations."/".proxyPass
);
};
local.enable = true;
};
};
};
}