factor(teslamate.nix): update domain, ports, and service configuration

- Updated domain to `tesla.giugl.io`
- Added separate ports for TeslaMate (`11234`) and Grafana (`11334`)
- Configured proxy settings for websockets in `/` and `/live/websocket` locations
- Added `/grafana` location with appropriate configuration
- Updated `services.teslamate` to include port, listen address, secrets file, virtual host, PostgreSQL server, and Grafana settings
This commit is contained in:
Giulio De Pasquale 2024-11-17 20:28:53 +00:00
parent 23ee309b8f
commit 2dc8e1b1a3

View File

@ -1,28 +1,35 @@
{ config, pkgs, lib, ... }: { config, pkgs, ... }:
let let
domain = "media.giugl.io"; domain = "tesla.giugl.io";
port = 8096; teslamatePort = 11234;
grafanaPort = 11334;
allowLan = true; allowLan = true;
allowWAN = false;
in in
{ {
# needed since StateDirectory does not accept symlinks
systemd.services.jellyfin.serviceConfig.StateDirectory = lib.mkForce "";
architect.vhost.${domain} = with config.architect.networks; { architect.vhost.${domain} = with config.architect.networks; {
dnsInterfaces = [ "lan" "tailscale" ]; dnsInterfaces = [ "lan" "tailscale" ];
locations = { locations = {
"/" = { "/" = {
inherit port allowLan; inherit allowLan allowWAN;
port = teslamatePort;
proxyWebsockets = true;
allow = [ allow = [
tailscale.net tailscale.net
]; ];
}; };
"/live/websocket" = {
"/socket" = { inherit allowLan allowWAN;
inherit port allowLan; port = teslamatePort;
proxyWebsockets = true;
allow = [
tailscale.net
];
};
"/grafana" = {
inherit allowLan allowWAN;
port = grafanaPort;
proxyWebsockets = true; proxyWebsockets = true;
allow = [ allow = [
tailscale.net tailscale.net
@ -33,6 +40,12 @@ in
services.teslamate = { services.teslamate = {
enable = true; enable = true;
package = pkgs.teslamatePkgs.teslamate; port = teslamatePort;
listenAddress = "127.0.0.1";
secretsFile = "/secrets/teslamate/teslamate.env";
virtualHost = domain;
postgres.enable_server = true;
grafana = { enable = true; port = grafanaPort; listenAddress = "127.0.0.1"; urlPath = "/grafana"; };
}; };
} }