From 6eba1a7a9d94245923324ed9b0c6f3a7eee5b569 Mon Sep 17 00:00:00 2001 From: "quentin@aristote.fr" Date: Mon, 24 Mar 2025 08:25:40 +0100 Subject: nixos: add system-wide enabling of monitoring --- modules/nixos/personal/monitoring.nix | 33 +++++++++++++++++++-------------- modules/nixos/personal/system.nix | 2 +- 2 files changed, 20 insertions(+), 15 deletions(-) (limited to 'modules/nixos') 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; }; -- cgit v1.2.3