feat(laptop): move power module into new laptop module
This commit is contained in:
		
							parent
							
								
									41ccb34bb3
								
							
						
					
					
						commit
						72011ba30a
					
				
					 5 changed files with 100 additions and 36 deletions
				
			
		|  | @ -4,6 +4,7 @@ | |||
|   imports = [ | ||||
|     ./hardware | ||||
|     ./bootloader | ||||
|     ./laptop | ||||
|     ./nix | ||||
|     ./programs | ||||
|     ./user | ||||
|  |  | |||
|  | @ -4,7 +4,6 @@ | |||
|   imports = [ | ||||
|     ./bluetooth.nix | ||||
|     ./backlight.nix | ||||
|     ./power.nix | ||||
|   ]; | ||||
| 
 | ||||
|   options.systemModules.hardware = { | ||||
|  | @ -14,8 +13,5 @@ | |||
|     backlight= { | ||||
|       enable = lib.mkEnableOption "Enable backlight module"; | ||||
|     }; | ||||
|     power = { | ||||
|       enable = lib.mkEnableOption "Enable power module"; | ||||
|     }; | ||||
|   }; | ||||
| } | ||||
|  |  | |||
|  | @ -1,32 +0,0 @@ | |||
| 
 | ||||
| { lib, config, ... }: | ||||
| 
 | ||||
| let | ||||
|   cfg = config.systemModules.hardware.power; | ||||
| in | ||||
| 
 | ||||
| { | ||||
|   config = lib.mkIf cfg.enable { | ||||
|     services.system76-scheduler.settings.cfsProfiles.enable = true; | ||||
| 
 | ||||
|     services.tlp = { | ||||
|       enable = true; | ||||
|       settings = { | ||||
|         cpu_boost_on_ac = 1; | ||||
|         cpu_boost_on_bat = 0; | ||||
|         cpu_scaling_governor_on_ac = "performance"; | ||||
|         cpu_scaling_governor_on_bat = "powersave"; | ||||
|       }; | ||||
|     }; | ||||
| 
 | ||||
|     services = { | ||||
|       upower.enable = true; | ||||
|       thermald.enable = true; | ||||
|       power-profiles-daemon.enable = false; | ||||
|       logind = { | ||||
|         lidSwitch = "suspend"; | ||||
|       }; | ||||
|     }; | ||||
|     powerManagement.powertop.enable = true; | ||||
|   }; | ||||
| } | ||||
							
								
								
									
										6
									
								
								system/modules/laptop/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										6
									
								
								system/modules/laptop/default.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,6 @@ | |||
| { | ||||
|   imports = [ | ||||
|     ./power | ||||
|     # ./touchpad | ||||
|   ]; | ||||
| } | ||||
							
								
								
									
										93
									
								
								system/modules/laptop/power/default.nix
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										93
									
								
								system/modules/laptop/power/default.nix
									
										
									
									
									
										Normal file
									
								
							|  | @ -0,0 +1,93 @@ | |||
| 
 | ||||
| { lib, config, pkgs, ... }: | ||||
| 
 | ||||
| let | ||||
|   cfg = config.systemModules.laptop.power; | ||||
|   inherit (lib) mkIf mkDefault mkEnableOption mkOption types; | ||||
|   MHz = x: x * 1000; | ||||
| in | ||||
|    | ||||
| { | ||||
|   options.systemModules.laptop.power = { | ||||
|     enable = mkEnableOption "Enable laptop power module"; | ||||
|     powersave = { | ||||
|       minFreq = mkOption { | ||||
|         type = types.int; | ||||
|         default = 800; | ||||
|         description = "Minimum frequency for powersave mode in MHz"; | ||||
|       }; | ||||
|       maxFreq = mkOption { | ||||
|         type = types.int; | ||||
|         default = 1100; | ||||
|         description = "Maximum frequency for powersave mode in MHz"; | ||||
|       }; | ||||
|     }; | ||||
|     performance = { | ||||
|       minFreq = mkOption { | ||||
|         type = types.int; | ||||
|         default = 1500; | ||||
|         description = "Minimum frequency for performance mode in MHz"; | ||||
|       }; | ||||
|       maxFreq = mkOption { | ||||
|         type = types.int; | ||||
|         default = 2600; | ||||
|         description = "Maximum frequency for performance mode in MHz"; | ||||
|       }; | ||||
|     }; | ||||
|   }; | ||||
| 
 | ||||
|   config = mkIf cfg.enable { | ||||
|     boot = { | ||||
|       kernelModules = ["acpi_call"]; | ||||
|       extraModulePackages = with config.boot.kernelPackages; [ | ||||
|         acpi_call | ||||
|         cpupower | ||||
|       ]; | ||||
|     }; | ||||
| 
 | ||||
|     services = { | ||||
|       auto-cpufreq = { | ||||
|         enable = true; | ||||
|         settings = { | ||||
|           battery = { | ||||
|             governor = "powersave"; | ||||
|             scaling_min_freq = mkDefault (MHz cfg.powersave.minFreq); | ||||
|             scaling_max_freq = mkDefault (MHz cfg.powersave.maxFreq); | ||||
|             turbo = "never"; | ||||
|           }; | ||||
|           charger = { | ||||
|             governor = "performance"; | ||||
|             scaling_min_freq = mkDefault (MHz cfg.performance.minFreq); | ||||
|             scaling_max_freq = mkDefault (MHz cfg.performance.maxFreq); | ||||
|             turbo = "auto"; | ||||
|           }; | ||||
|         }; | ||||
|       }; | ||||
| 
 | ||||
|       upower = { | ||||
|         enable = true; | ||||
|         percentageLow = 25; | ||||
|         percentageCritical = 5; | ||||
|         percentageAction = 3; | ||||
|         criticalPowerAction = "Hibernate"; | ||||
|       }; | ||||
| 
 | ||||
|       undervolt = { | ||||
|         enable = true; | ||||
|         tempBat = 65; | ||||
|       }; | ||||
| 
 | ||||
|       thermald.enable = true; | ||||
| 
 | ||||
|       power-profiles-daemon.enable = true; | ||||
| 
 | ||||
|       logind = { | ||||
|         lidSwitch = "suspend"; | ||||
|       }; | ||||
|     }; | ||||
|     environment.systemPackages = with pkgs; [ | ||||
|       acpi | ||||
|       powertop | ||||
|     ]; | ||||
|   }; | ||||
| } | ||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue