at 15.09-beta 1.1 kB view raw
1# Monit system watcher 2# http://mmonit.org/monit/ 3 4{config, pkgs, lib, ...}: 5 6let inherit (lib) mkOption mkIf; 7in 8 9{ 10 options = { 11 services.monit = { 12 enable = mkOption { 13 default = false; 14 description = '' 15 Whether to run Monit system watcher. 16 ''; 17 }; 18 config = mkOption { 19 default = ""; 20 description = "monit.conf content"; 21 }; 22 startOn = mkOption { 23 default = "started network-interfaces"; 24 description = "What Monit supposes to be already present"; 25 }; 26 }; 27 }; 28 29 config = mkIf config.services.monit.enable { 30 31 environment.etc = [ 32 { 33 source = pkgs.writeTextFile { 34 name = "monit.conf"; 35 text = config.services.monit.config; 36 }; 37 target = "monit.conf"; 38 mode = "0400"; 39 } 40 ]; 41 42 jobs.monit = { 43 description = "Monit system watcher"; 44 45 startOn = config.services.monit.startOn; 46 47 exec = "${pkgs.monit}/bin/monit -I -c /etc/monit.conf"; 48 49 respawn = true; 50 }; 51 }; 52}