2023-03-17 20:58:31 +00:00
|
|
|
{ config, ... }:
|
|
|
|
|
2022-07-30 22:36:06 +00:00
|
|
|
let
|
2023-03-17 20:58:31 +00:00
|
|
|
secret = import ../../secret/container/weewx;
|
|
|
|
data-dir = "/etc/container-weewx";
|
2022-07-30 22:36:06 +00:00
|
|
|
in
|
|
|
|
{
|
2023-03-17 20:58:31 +00:00
|
|
|
virtualisation.arion.projects.weewx.settings = {
|
2022-07-30 22:36:06 +00:00
|
|
|
services = {
|
2022-07-31 14:40:01 +00:00
|
|
|
weewx = {
|
|
|
|
service = {
|
|
|
|
image = "ghcr.io/nifoc/weewx-docker:master";
|
2022-11-19 18:09:40 +00:00
|
|
|
container_name = "weewx";
|
2022-08-02 19:05:58 +00:00
|
|
|
restart = "unless-stopped";
|
2022-12-26 16:53:21 +00:00
|
|
|
ports = [ "127.0.0.1:8000:8000" ];
|
2022-07-31 14:40:01 +00:00
|
|
|
environment = {
|
|
|
|
"TZ" = "Europe/Berlin";
|
|
|
|
};
|
|
|
|
volumes = [
|
2023-03-17 20:58:31 +00:00
|
|
|
"${data-dir}:/data"
|
2022-07-31 14:40:01 +00:00
|
|
|
];
|
2023-02-19 22:34:09 +00:00
|
|
|
labels = {
|
|
|
|
"com.centurylinklabs.watchtower.enable" = "true";
|
|
|
|
};
|
2023-01-22 12:47:36 +00:00
|
|
|
};
|
|
|
|
};
|
2022-07-30 22:36:06 +00:00
|
|
|
};
|
|
|
|
};
|
2023-03-06 21:20:26 +00:00
|
|
|
|
2023-03-17 20:58:31 +00:00
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d ${data-dir} 0755 421 421"
|
|
|
|
"d ${data-dir}/html 0755 421 421"
|
|
|
|
];
|
|
|
|
|
|
|
|
environment.etc."container-weewx/weewx.conf" = {
|
|
|
|
source = ../../secret/container/weewx/config/weewx.conf;
|
|
|
|
mode = "0644";
|
|
|
|
uid = 421;
|
|
|
|
gid = 421;
|
|
|
|
};
|
|
|
|
|
|
|
|
services.mosquitto.listeners = {
|
|
|
|
weewx-private = {
|
|
|
|
address = "0.0.0.0";
|
|
|
|
port = 1883;
|
|
|
|
|
|
|
|
users = {
|
|
|
|
weewx-proxy = {
|
|
|
|
hashedPasswordFile = config.age.secrets.mosquitto-password-weewx-proxy.path;
|
|
|
|
acl = [ "write weewx/+" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
weewx = {
|
|
|
|
hashedPasswordFile = config.age.secrets.mosquitto-password-weewx.path;
|
|
|
|
acl = [ "read weewx/+" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
networking.firewall.interfaces."enp7s0".allowedTCPPorts = [ 1883 ];
|
|
|
|
networking.firewall.interfaces."tailscale0".allowedTCPPorts = [ 1883 ];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${secret.container.weewx.hostname}" = {
|
2023-03-06 21:20:26 +00:00
|
|
|
http3 = true;
|
2023-03-12 11:22:44 +00:00
|
|
|
kTLS = true;
|
2023-03-06 21:20:26 +00:00
|
|
|
|
2023-03-17 20:58:31 +00:00
|
|
|
root = "${data-dir}/html/wdc";
|
2023-03-06 21:20:26 +00:00
|
|
|
forceSSL = true;
|
|
|
|
useACMEHost = "kempkens.io";
|
|
|
|
|
2023-03-06 21:21:22 +00:00
|
|
|
extraConfig = ''
|
|
|
|
index index.html;
|
2023-03-06 22:39:49 +00:00
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
|
2023-03-06 21:21:22 +00:00
|
|
|
'';
|
|
|
|
|
2023-03-06 21:22:15 +00:00
|
|
|
locations."~* \.html$".extraConfig = ''
|
2023-03-06 21:20:26 +00:00
|
|
|
expires modified 120s;
|
|
|
|
'';
|
|
|
|
|
2023-03-06 21:22:15 +00:00
|
|
|
locations."~* \.(js|css)$".extraConfig = ''
|
2023-03-06 21:20:26 +00:00
|
|
|
expires 1h;
|
|
|
|
'';
|
|
|
|
|
|
|
|
locations."~ ^/dwd/(icons|warn_icons)/" = {
|
|
|
|
recommendedProxySettings = true;
|
|
|
|
proxyPass = "http://127.0.0.1:8000";
|
|
|
|
};
|
|
|
|
|
2023-03-06 21:22:15 +00:00
|
|
|
locations."~ ^/dwd/[\w]+\.(gif|png)".extraConfig = ''
|
2023-03-06 21:20:26 +00:00
|
|
|
expires modified 1h;
|
|
|
|
'';
|
|
|
|
};
|
2023-03-17 20:58:31 +00:00
|
|
|
}
|