git.iko.soy/typeable/nixpkgs
on master help sign in
Merge pull request #87553 from JoeDupuis/enhancing-monit-module

nixos/monit: Allow splitting the config in multiple files

commit2fb9ee9caa4cd7359ba28ec147646d67189218ac authorLassulus <github@lassul.us> dateSat 22 Aug 2020, 19:21 (6 years ago) parentecaebb08f4070c
1 file changed+14−4
nixos/modules/services/monitoring/monit.nix+14−4
nixos/modules/services/monitoring/monit.nix+14−4
@@ -4,19 +4,29 @@ with lib;
44
55let
66 cfg = config.services.monit;
7+ extraConfig = pkgs.writeText "monitConfig" cfg.extraConfig;
78in
89
910{
11+ imports = [
12+ (mkRenamedOptionModule [ "services" "monit" "config" ] ["services" "monit" "extraConfig" ])
13+ ];
14+
1015 options.services.monit = {
1116
1217 enable = mkEnableOption "Monit";
1318
14− config = mkOption {
19+ configFiles = mkOption {
20+ type = types.listOf types.path;
21+ default = [];
22+ description = "List of paths to be included in the monitrc file";
23+ };
24+
25+ extraConfig = mkOption {
1526 type = types.lines;
1627 default = "";
17− description = "monitrc content";
28+ description = "Additional monit config as string";
1829 };
19−
2030 };
2131
2232 config = mkIf cfg.enable {
@@ -24,7 +34,7 @@ in
2434 environment.systemPackages = [ pkgs.monit ];
2535
2636 environment.etc.monitrc = {
27− text = cfg.config;
37+ text = concatMapStringsSep "\n" (path: "include ${path}") (cfg.configFiles ++ [extraConfig]);
2838 mode = "0400";
2939 };
3040