| 
									
										
										
										
											2017-04-15 14:36:10 +02:00
										 |  |  | { config, lib, pkgs, ... }: | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | with lib; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | let | 
					
						
							| 
									
										
										
										
											2017-05-16 12:22:44 -04:00
										 |  |  |   cfg = config.powerManagement.powertop; | 
					
						
							| 
									
										
										
										
											2017-04-15 14:36:10 +02:00
										 |  |  | in { | 
					
						
							|  |  |  |   ###### interface | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-05-16 12:22:44 -04:00
										 |  |  |   options.powerManagement.powertop.enable = mkEnableOption "powertop auto tuning on startup"; | 
					
						
							| 
									
										
										
										
											2017-04-15 14:36:10 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |   ###### implementation | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   config = mkIf (cfg.enable) { | 
					
						
							|  |  |  |     systemd.services = { | 
					
						
							|  |  |  |       powertop = { | 
					
						
							|  |  |  |         wantedBy = [ "multi-user.target" ]; | 
					
						
							|  |  |  |         description = "Powertop tunings"; | 
					
						
							| 
									
										
										
										
											2017-10-07 21:45:43 +01:00
										 |  |  |         path = [ pkgs.kmod ]; | 
					
						
							| 
									
										
										
										
											2017-04-15 14:36:10 +02:00
										 |  |  |         serviceConfig = { | 
					
						
							|  |  |  |           Type = "oneshot"; | 
					
						
							|  |  |  |           RemainAfterExit = "yes"; | 
					
						
							|  |  |  |           ExecStart = "${pkgs.powertop}/bin/powertop --auto-tune"; | 
					
						
							|  |  |  |         }; | 
					
						
							|  |  |  |       }; | 
					
						
							|  |  |  |     }; | 
					
						
							|  |  |  |   }; | 
					
						
							|  |  |  | } |