bunch of framework power updates, suspend to hibernate etc
This commit is contained in:
parent
68b3c6f857
commit
1d34d1bdfb
1 changed files with 59 additions and 52 deletions
|
|
@ -1,80 +1,87 @@
|
||||||
{ config, lib, pkgs, modulesPath, ... }: {
|
{ config, lib, pkgs, modulesPath, ... }: {
|
||||||
|
|
||||||
networking.hostName = "framework";
|
networking.hostName = "framework";
|
||||||
|
|
||||||
# CPU Stuff
|
# CPU Settings
|
||||||
|
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||||
hardware.cpu.amd.updateMicrocode =
|
|
||||||
lib.mkDefault config.hardware.enableRedistributableFirmware;
|
|
||||||
|
|
||||||
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
|
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "nvme" "usb_storage" "sd_mod" ];
|
||||||
boot.initrd.kernelModules = [ ];
|
boot.initrd.kernelModules = [];
|
||||||
boot.kernelModules = [ "kvm-intel" ];
|
boot.kernelModules = [ "kvm-amd" ]; # Include kvm-amd for virtualization support
|
||||||
boot.extraModulePackages = [ ];
|
boot.extraModulePackages = [];
|
||||||
|
|
||||||
networking.useDHCP = lib.mkDefault true;
|
networking.useDHCP = lib.mkDefault true;
|
||||||
# networking.interfaces.wlp166s0.useDHCP = lib.mkDefault true;
|
|
||||||
|
|
||||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||||
powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
|
|
||||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault
|
|
||||||
config.hardware.enableRedistributableFirmware;
|
|
||||||
hardware.keyboard.qmk.enable = true;
|
|
||||||
|
|
||||||
# For fingerprint support
|
# Enable TLP for power management
|
||||||
# services.fprintd.enable = lib.mkDefault true;
|
|
||||||
|
|
||||||
# FSTrim for the SSD
|
|
||||||
services.fstrim.enable = lib.mkDefault true;
|
|
||||||
|
|
||||||
# Custom udev rules
|
|
||||||
services.udev.extraRules = ''
|
|
||||||
# Fix headphone noise when on powersave
|
|
||||||
# https://community.frame.work/t/headphone-jack-intermittent-noise/5246/55
|
|
||||||
SUBSYSTEM=="pci", ATTR{vendor}=="0x8086", ATTR{device}=="0xa0e0", ATTR{power/control}="on"
|
|
||||||
# Ethernet expansion card support
|
|
||||||
ACTION=="add", SUBSYSTEM=="usb", ATTR{idVendor}=="0bda", ATTR{idProduct}=="8156", ATTR{power/autosuspend}="20"
|
|
||||||
'';
|
|
||||||
|
|
||||||
# Mis-detected by nixos-generate-config
|
|
||||||
# https://github.com/NixOS/nixpkgs/issues/171093
|
|
||||||
# https://wiki.archlinux.org/title/Framework_Laptop#Changing_the_brightness_of_the_monitor_does_not_work
|
|
||||||
hardware.acpilight.enable = lib.mkDefault true;
|
|
||||||
|
|
||||||
# Enable firmware updating
|
|
||||||
services.fwupd.enable = true;
|
|
||||||
|
|
||||||
# Power Stuff
|
|
||||||
services.power-profiles-daemon.enable = false;
|
|
||||||
# services.throttled.enable = true; //disabled due to errors on applying system config
|
|
||||||
services.tlp = {
|
services.tlp = {
|
||||||
enable = true;
|
enable = true;
|
||||||
settings = {
|
settings = {
|
||||||
CPU_BOOST_ON_BAT = 0;
|
CPU_BOOST_ON_BAT = 0;
|
||||||
CPU_SCALING_GOVERNOR_ON_BATTERY = "powersave";
|
CPU_SCALING_GOVERNOR_ON_BATTERY = "powersave";
|
||||||
CPU_SCALING_GOVERNOR_ON_AC= "performance";
|
CPU_SCALING_GOVERNOR_ON_AC = "performance";
|
||||||
CPU_ENERGY_PERF_POLICY_ON_AC= "balance_performance";
|
CPU_ENERGY_PERF_POLICY_ON_AC = "balance_performance";
|
||||||
START_CHARGE_THRESH_BAT0 = 90;
|
START_CHARGE_THRESH_BAT0 = 90;
|
||||||
STOP_CHARGE_THRESH_BAT0 = 97;
|
STOP_CHARGE_THRESH_BAT0 = 97;
|
||||||
RUNTIME_PM_ON_BAT = "auto";
|
RUNTIME_PM_ON_BAT = "auto";
|
||||||
|
HANDLE_LID_SWITCH = 1; # Suspend on lid close
|
||||||
|
HANDLE_LID_SWITCH_DOCKED = 0; # Do nothing when docked
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Disable power-profiles-daemon to resolve conflict
|
||||||
|
services.power-profiles-daemon.enable = false;
|
||||||
|
|
||||||
|
# GPU settings
|
||||||
services.xserver.videoDrivers = [ "amdgpu" ];
|
services.xserver.videoDrivers = [ "amdgpu" ];
|
||||||
# Optionally set environment variable so everything defaults to iGPU
|
|
||||||
environment.variables = {
|
environment.variables = {
|
||||||
DRI_PRIME = "1";
|
DRI_PRIME = "1"; # Ensure iGPU is default
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# Brightness control
|
||||||
|
hardware.acpilight.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# SSD optimization
|
||||||
|
services.fstrim.enable = lib.mkDefault true;
|
||||||
|
|
||||||
|
# Logind lid-switch configuration
|
||||||
|
services.logind = {
|
||||||
|
lidSwitch = "suspend";
|
||||||
|
lidSwitchDocked = "ignore"; # Prevent suspend when connected to a dock
|
||||||
|
powerKey = "poweroff"; # Optional: configure behavior for the power key
|
||||||
|
suspendKey = "suspend"; # Optional: configure behavior for the suspend key
|
||||||
|
};
|
||||||
|
|
||||||
|
# Suspend-then-hibernate configuration
|
||||||
|
systemd.services.suspendThenHibernate = {
|
||||||
|
description = "Suspend and then hibernate";
|
||||||
|
after = [ "suspend.target" ];
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = "/bin/sh -c 'sleep 3600 && systemctl hibernate'"; # Hibernate after 60 minutes
|
||||||
|
Type = "oneshot";
|
||||||
|
};
|
||||||
|
wantedBy = [ "suspend.target" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
# Custom udev rules for runtime PM
|
||||||
|
services.udev.extraRules = ''
|
||||||
|
ACTION=="add", SUBSYSTEM=="pci", ATTR{power/control}="auto"
|
||||||
|
ACTION=="add", SUBSYSTEM=="usb", ATTR{power/autosuspend}="10"
|
||||||
|
'';
|
||||||
|
|
||||||
|
# ACPI lid event handler
|
||||||
|
environment.etc."acpi/events/lid".source = pkgs.writeText "lid-event-handler" ''
|
||||||
|
event=button/lid.*
|
||||||
|
action=/etc/acpi/actions/lid.sh
|
||||||
|
'';
|
||||||
|
environment.etc."acpi/actions/lid.sh".source = pkgs.writeText "lid-sh-handler" ''
|
||||||
|
#!/bin/bash
|
||||||
|
systemctl suspend
|
||||||
|
'';
|
||||||
|
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
via
|
via
|
||||||
radeontop
|
radeontop
|
||||||
|
amdvlk
|
||||||
];
|
];
|
||||||
services.udev.packages = [ pkgs.via ];
|
|
||||||
|
|
||||||
networking.bridges = {
|
|
||||||
"br0" = {
|
|
||||||
interfaces = [ "wlan0" ];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue