mirror of
https://github.com/JulienMalka/snowfield.git
synced 2025-03-26 05:40:52 +01:00
52 lines
1.4 KiB
Nix
52 lines
1.4 KiB
Nix
{ lib, pkgs, config, ... }:
|
|
with lib;
|
|
let
|
|
cfg = config.luj.status;
|
|
in
|
|
{
|
|
|
|
options.luj.status = {
|
|
enable = mkEnableOption "activate status page";
|
|
nginx.enable = mkEnableOption "activate nginx";
|
|
nginx.subdomain = mkOption {
|
|
type = types.str;
|
|
};
|
|
};
|
|
|
|
config = mkIf cfg.enable (
|
|
mkMerge [{
|
|
systemd = {
|
|
timers.tinystatus = {
|
|
wantedBy = [ "timers.target" ];
|
|
partOf = [ "tinystatus.service" ];
|
|
timerConfig.OnCalendar = "*-*-* *:05,10,15,20,25,30,35,40,45,50,55:00";
|
|
timerConfig.Unit = "tinystatus.service";
|
|
};
|
|
services.tinystatus = {
|
|
serviceConfig.Type = "oneshot";
|
|
path = [ pkgs.gawk pkgs.gnused pkgs.curl pkgs.netcat pkgs.unixtools.ping ];
|
|
script = ''
|
|
mkdir -p /var/www/status
|
|
${pkgs.tinystatus}/bin/tinystatus ${./checks.csv} > /var/www/status/index.html
|
|
${pkgs.gnused}/bin/sed -i 's/tinystatus/Services status/g' /var/www/status/index.html
|
|
${pkgs.gnused}/bin/sed -i 's/80%/60%/g' /var/www/status/index.html
|
|
'';
|
|
};
|
|
};
|
|
}
|
|
|
|
|
|
(mkIf cfg.nginx.enable {
|
|
luj.nginx.enable = true;
|
|
services.nginx.virtualHosts."${cfg.nginx.subdomain}.julienmalka.me" = {
|
|
enableACME = true;
|
|
forceSSL = true;
|
|
root = "/var/www/status/";
|
|
};
|
|
|
|
})]);
|
|
|
|
|
|
|
|
|
|
}
|