-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d611822
commit 8287125
Showing
5 changed files
with
131 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
let | ||
cfg = config.nixos.laptop.tlp; | ||
in | ||
{ | ||
options.nixos.laptop.tlp = { | ||
enable = lib.mkEnableOption "TLP config" // { | ||
default = config.nixos.laptop.enable; | ||
}; | ||
cpuFreqGovernor = lib.mkOption { | ||
default = config.powerManagement.cpuFreqGovernor; | ||
types = lib.types.nullOr lib.types.string; | ||
example = "schedutil"; | ||
description = "CPU frequency governor to be set via TLP."; | ||
}; | ||
batteryThreshold = { | ||
start = lib.mkOption { | ||
default = 0; | ||
types = lib.types.int; | ||
description = "Start of battery charging threshold"; | ||
}; | ||
stop = lib.mkOption { | ||
default = 0; | ||
types = lib.types.int; | ||
description = "Stop of battery charging threshold"; | ||
}; | ||
}; | ||
}; | ||
|
||
config = lib.mkIf cfg.enable { | ||
# Reduce power consumption | ||
services.tlp = { | ||
enable = true; | ||
# https://linrunner.de/tlp/support/optimizing.html | ||
settings = { | ||
# Enable the platform profile low-power | ||
PLATFORM_PROFILE_ON_BAT = lib.mkDefault "balanced"; | ||
# Enable the platform profile performance | ||
PLATFORM_PROFILE_ON_AC = lib.mkDefault "performance"; | ||
# Enable runtime power management | ||
RUNTIME_PM_ON_AC = lib.mkDefault "auto"; | ||
# CPU frequency governor | ||
CPU_SCALING_GOVERNOR_ON_AC = lib.mkIf (cfg.cpuFreqGovernor != null) cfg.cpuFreqGovernor; | ||
CPU_SCALING_GOVERNOR_ON_BAT = lib.mkIf (cfg.cpuFreqGovernor != null) cfg.cpuFreqGovernor; | ||
# Set battery thresholds | ||
START_CHARGE_THRESH_BAT0 = cfg.batteryThreshold.start; | ||
STOP_CHARGE_THRESH_BAT0 = cfg.batteryThreshold.stop; | ||
# Use `tlp setcharge` to restore the charging thresholds | ||
RESTORE_THRESHOLDS_ON_BAT = lib.mkDefault 1; | ||
}; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ config, pkgs, lib, ... }: | ||
|
||
{ | ||
options.nixos.laptop.wireless.enable = lib.mkEnableOption "Wi-Fi/Bluetooth config" // { | ||
default = config.nixos.laptop.enable; | ||
}; | ||
|
||
config = lib.mkIf config.nixos.laptop.enable { | ||
networking = { | ||
# Use Network Manager | ||
networkmanager = { | ||
enable = true; | ||
wifi.backend = "iwd"; | ||
}; | ||
}; | ||
|
||
# Install Wireless related packages | ||
environment.systemPackages = with pkgs; [ iw ]; | ||
|
||
# Enable bluetooth | ||
hardware.bluetooth.enable = true; | ||
|
||
# Enable NetworkManager applet | ||
programs.nm-applet.enable = true; | ||
|
||
# Make nm-applet restart in case of failure | ||
systemd.user.services.nm-applet = { | ||
serviceConfig = { | ||
RestartSec = 3; | ||
Restart = "on-failure"; | ||
}; | ||
}; | ||
|
||
# Wireless related config | ||
services = { | ||
# Enable Blueman to manage Bluetooth | ||
blueman.enable = true; | ||
|
||
# Use systemd-resolved for DNS | ||
resolved = { | ||
enable = true; | ||
# Can make DNS lookups really slow | ||
dnssec = "false"; | ||
}; | ||
}; | ||
}; | ||
} |