diff options
| author | aristote <quentin.aristote@irif.fr> | 2025-07-29 15:25:11 +0200 |
|---|---|---|
| committer | aristote <quentin.aristote@irif.fr> | 2025-07-29 15:25:11 +0200 |
| commit | fc019d789523ce5f89436b8dbc458cf3b79abf43 (patch) | |
| tree | ec56fd1b1ed9fc75096c0b09db48a152975e4d53 /modules/nixos/personal/monitoring.nix | |
| parent | a3d19bc509d9f39fb41256cd55d2bd7706de202f (diff) | |
reformat everything with nixfmt
Diffstat (limited to 'modules/nixos/personal/monitoring.nix')
| -rw-r--r-- | modules/nixos/personal/monitoring.nix | 57 |
1 files changed, 33 insertions, 24 deletions
diff --git a/modules/nixos/personal/monitoring.nix b/modules/nixos/personal/monitoring.nix index 01fe201..e5797fb 100644 --- a/modules/nixos/personal/monitoring.nix +++ b/modules/nixos/personal/monitoring.nix @@ -3,23 +3,30 @@ lib, pkgs, ... -}: let +}: +let cfg = config.personal.monitoring; -in { +in +{ options = { personal.monitoring.enable = lib.mkEnableOption "e-mail monitoring of systemd services"; systemd.services = lib.mkOption { - type = with lib.types; - attrsOf (submodule ({ - name, - config, - lib, - ... - }: { - options.personal.monitor = - lib.mkEnableOption "e-mail monitoring for the ${name} seervice"; - config.onFailure = lib.optional config.personal.monitor "notify@%i.service"; - })); + type = + with lib.types; + attrsOf ( + submodule ( + { + name, + config, + lib, + ... + }: + { + options.personal.monitor = lib.mkEnableOption "e-mail monitoring for the ${name} seervice"; + config.onFailure = lib.optional config.personal.monitor "notify@%i.service"; + } + ) + ); }; }; @@ -42,18 +49,20 @@ in { description = "Send the status of the %i service as an e-mail."; serviceConfig.type = "oneshot"; scriptArgs = "%i"; - script = let - netCfg = config.networking; - host = "${builtins.toString netCfg.hostName}.${builtins.toString netCfg.domain}"; - in '' - service="$1" - echo \ - "Subject: ${host}: service $service failed - Service $soervice failed on ${host}, with the following log: + script = + let + netCfg = config.networking; + host = "${builtins.toString netCfg.hostName}.${builtins.toString netCfg.domain}"; + in + '' + service="$1" + echo \ + "Subject: ${host}: service $service failed + Service $soervice failed on ${host}, with the following log: - $(journalctl --no-pager --unit $service --since -1h) - " | ${pkgs.msmtp}/bin/msmtp quentin@aristote.fr - ''; + $(journalctl --no-pager --unit $service --since -1h) + " | ${pkgs.msmtp}/bin/msmtp quentin@aristote.fr + ''; }; }; } |
