From 8f4070c4c6a48a5360ecfa6f803e36dfc3ca822c Mon Sep 17 00:00:00 2001 From: Joe Dupuis Date: Sat, 9 May 2020 21:10:06 -0400 Subject: [PATCH] nixos/monit: Allow splitting the config in multiple files --- nixos/modules/services/monitoring/monit.nix | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/nixos/modules/services/monitoring/monit.nix b/nixos/modules/services/monitoring/monit.nix index ca9352272174..aa51b83912ce 100644 --- a/nixos/modules/services/monitoring/monit.nix +++ b/nixos/modules/services/monitoring/monit.nix @@ -4,19 +4,29 @@ with lib; let cfg = config.services.monit; + extraConfig = pkgs.writeText "monitConfig" cfg.extraConfig; in { + imports = [ + (mkRenamedOptionModule [ "services" "monit" "config" ] ["services" "monit" "extraConfig" ]) + ]; + options.services.monit = { enable = mkEnableOption "Monit"; - config = mkOption { - type = types.lines; - default = ""; - description = "monitrc content"; + configFiles = mkOption { + type = types.listOf types.path; + default = []; + description = "List of paths to be included in the monitrc file"; }; + extraConfig = mkOption { + type = types.lines; + default = ""; + description = "Additional monit config as string"; + }; }; config = mkIf cfg.enable { @@ -24,7 +34,7 @@ in environment.systemPackages = [ pkgs.monit ]; environment.etc.monitrc = { - text = cfg.config; + text = concatMapStringsSep "\n" (path: "include ${path}") (cfg.configFiles ++ [extraConfig]); mode = "0400"; };