diff options
| author | quentin@aristote.fr <quentin@aristote.fr> | 2025-03-24 08:25:40 +0100 |
|---|---|---|
| committer | quentin@aristote.fr <quentin@aristote.fr> | 2025-03-24 08:31:13 +0100 |
| commit | 6eba1a7a9d94245923324ed9b0c6f3a7eee5b569 (patch) | |
| tree | d4499591991ff1749aee1a5c34c1c9dd9642e091 /modules/nixos | |
| parent | 48292efe71a7f8e140cf9d5c86c7960bcc64433a (diff) | |
nixos: add system-wide enabling of monitoring
Diffstat (limited to 'modules/nixos')
| -rw-r--r-- | modules/nixos/personal/monitoring.nix | 33 | ||||
| -rw-r--r-- | modules/nixos/personal/system.nix | 2 |
2 files changed, 20 insertions, 15 deletions
diff --git a/modules/nixos/personal/monitoring.nix b/modules/nixos/personal/monitoring.nix index e054c51..01fe201 100644 --- a/modules/nixos/personal/monitoring.nix +++ b/modules/nixos/personal/monitoring.nix @@ -3,22 +3,27 @@ lib, pkgs, ... -}: { - options.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"; - })); +}: let + cfg = config.personal.monitoring; +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"; + })); + }; }; - config = { + config = lib.mkIf cfg.enable { programs.msmtp = { enable = true; accounts.default = { diff --git a/modules/nixos/personal/system.nix b/modules/nixos/personal/system.nix index 51f3351..4ed6fb2 100644 --- a/modules/nixos/personal/system.nix +++ b/modules/nixos/personal/system.nix @@ -70,7 +70,7 @@ in { StartLimitIntervalSec = 300; StartLimitBurst = 5; }; - serviceConfig = { + serviceConfig = lib.mkIf (!config.personal.monitoring.enable) { Restart = "on-abort"; RestartSec = 30; }; |
