| 
									
										
										
										
											2014-04-14 16:26:48 +02:00
										 |  |  | { config, lib, pkgs, ... }: | 
					
						
							| 
									
										
										
										
											2010-04-29 18:54:08 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-04-14 16:26:48 +02:00
										 |  |  | with lib; | 
					
						
							| 
									
										
										
										
											2010-04-29 18:54:08 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  |   cfg = config.services.logrotate; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   configFile = pkgs.writeText "logrotate.conf" | 
					
						
							|  |  |  |     cfg.config; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | in | 
					
						
							|  |  |  | { | 
					
						
							|  |  |  |   options = { | 
					
						
							|  |  |  |     services.logrotate = { | 
					
						
							|  |  |  |       enable = mkOption { | 
					
						
							| 
									
										
										
										
											2016-01-17 19:34:55 +01:00
										 |  |  |         type = lib.types.bool; | 
					
						
							| 
									
										
										
										
											2010-04-29 18:54:08 +00:00
										 |  |  |         default = false; | 
					
						
							|  |  |  |         description = ''
 | 
					
						
							|  |  |  |           Enable the logrotate cron job | 
					
						
							|  |  |  |         '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       config = mkOption { | 
					
						
							|  |  |  |         default = ""; | 
					
						
							| 
									
										
										
										
											2014-10-16 08:20:43 +02:00
										 |  |  |         type = types.lines; | 
					
						
							| 
									
										
										
										
											2010-04-29 18:54:08 +00:00
										 |  |  |         description = ''
 | 
					
						
							|  |  |  |           The contents of the logrotate config file | 
					
						
							|  |  |  |         '';
 | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = mkIf cfg.enable { | 
					
						
							| 
									
										
										
										
											2014-07-10 13:11:35 +02:00
										 |  |  |     systemd.services.logrotate = { | 
					
						
							|  |  |  |       description   = "Logrotate Service"; | 
					
						
							|  |  |  |       wantedBy      = [ "multi-user.target" ]; | 
					
						
							|  |  |  |       startAt       = "*-*-* *:05:00"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       serviceConfig.Restart = "no"; | 
					
						
							|  |  |  |       serviceConfig.User    = "root"; | 
					
						
							|  |  |  |       script = ''
 | 
					
						
							|  |  |  |         exec ${pkgs.logrotate}/sbin/logrotate ${configFile} | 
					
						
							|  |  |  |       '';
 | 
					
						
							|  |  |  |     }; | 
					
						
							| 
									
										
										
										
											2010-04-29 18:54:08 +00:00
										 |  |  |   }; | 
					
						
							|  |  |  | } |