| 
									
										
										
										
											2014-12-03 15:49:14 +01:00
										 |  |  | { config, lib, pkgs, ... }: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | with lib; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							|  |  |  |   cfg = config.services.chronos; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | in { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ###### interface | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   options.services.chronos = { | 
					
						
							|  |  |  |     enable = mkOption { | 
					
						
							|  |  |  |       description = "Whether to enable graphite web frontend."; | 
					
						
							|  |  |  |       default = false; | 
					
						
							| 
									
										
										
										
											2015-06-15 18:10:26 +02:00
										 |  |  |       type = types.bool; | 
					
						
							| 
									
										
										
										
											2014-12-03 15:49:14 +01:00
										 |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     httpPort = mkOption { | 
					
						
							|  |  |  |       description = "Chronos listening port"; | 
					
						
							| 
									
										
										
										
											2015-02-19 12:31:12 +02:00
										 |  |  |       default = 4400; | 
					
						
							| 
									
										
										
										
											2014-12-03 15:49:14 +01:00
										 |  |  |       type = types.int; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     master = mkOption { | 
					
						
							|  |  |  |       description = "Chronos mesos master zookeeper address"; | 
					
						
							|  |  |  |       default = "zk://${head cfg.zookeeperHosts}/mesos"; | 
					
						
							|  |  |  |       type = types.str; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     zookeeperHosts = mkOption { | 
					
						
							|  |  |  |       description = "Chronos mesos zookepper addresses"; | 
					
						
							|  |  |  |       default = [ "localhost:2181" ]; | 
					
						
							|  |  |  |       type = types.listOf types.str; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   ###### implementation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = mkIf cfg.enable { | 
					
						
							|  |  |  |     systemd.services.chronos = { | 
					
						
							|  |  |  |       description = "Chronos Service"; | 
					
						
							|  |  |  |       wantedBy = [ "multi-user.target" ]; | 
					
						
							| 
									
										
										
										
											2016-09-10 20:19:48 +02:00
										 |  |  |       after = [ "network.target" "zookeeper.service" ]; | 
					
						
							| 
									
										
										
										
											2014-12-03 15:49:14 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |       serviceConfig = { | 
					
						
							|  |  |  |         ExecStart = "${pkgs.chronos}/bin/chronos --master ${cfg.master} --zk_hosts ${concatStringsSep "," cfg.zookeeperHosts} --http_port ${toString cfg.httpPort}"; | 
					
						
							|  |  |  |         User = "chronos"; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     users.extraUsers.chronos.uid = config.ids.uids.chronos; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |