2023-03-18 08:16:25 +01:00
|
|
|
{ lib, pkgs, config, assets, ... }:
|
|
|
|
{
|
|
|
|
|
|
|
|
networking.firewall.allowedTCPPorts = [ 80 ];
|
|
|
|
networking.firewall.allowedUDPPorts = [ 80 ];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."${config.networking.hostName}.private" = {
|
|
|
|
locations."= /home-status.html".alias = "/srv/home-status/index.html";
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.home-status-refresh = {
|
|
|
|
enable = true;
|
|
|
|
script =
|
|
|
|
let
|
|
|
|
mustache = "${pkgs.mustache-go}/bin/mustache";
|
|
|
|
jq = "${pkgs.jq}/bin/jq";
|
|
|
|
index_html_template = refreshSeconds: pkgs.writeText "index_html.template" ''
|
2023-04-11 10:42:00 +02:00
|
|
|
<html>
|
|
|
|
<head><meta http-equiv="refresh" content="${toString refreshSeconds}"></head>
|
|
|
|
<body>{{ date }}</body>
|
|
|
|
</html>
|
2023-03-18 08:16:25 +01:00
|
|
|
'';
|
|
|
|
in
|
|
|
|
|
|
|
|
''
|
|
|
|
${jq} --raw-input '.' <(date +"%Y-%m-%d %H:%M";echo "hallo") \
|
|
|
|
| ${jq} --slurp '{ date : .[0], test : .[1] }' \
|
|
|
|
| ${mustache} ${index_html_template 60} > /srv/home-status/index.html
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.timers.home-status-refresh = {
|
|
|
|
enable = true;
|
|
|
|
# man systemd.time
|
|
|
|
timerConfig.OnCalendar = "minutely";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|