41 lines
1.1 KiB
Nix
41 lines
1.1 KiB
Nix
|
{ 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" ''
|
||
|
<html>
|
||
|
<head><meta http-equiv="refresh" content="${toString refreshSeconds}"></head>
|
||
|
<body>{{ date }}</body>
|
||
|
</html>
|
||
|
'';
|
||
|
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" ];
|
||
|
};
|
||
|
|
||
|
}
|
||
|
|