From 965583c2d8d9bc0b98be5776eb8218f610ade8b3 Mon Sep 17 00:00:00 2001 From: Ari Sosnovsky Date: Wed, 9 Oct 2024 09:44:29 -0400 Subject: [PATCH] fixed aliases for git + took out pwr management into a module --- modules/home/gitconfigs/alias.conf | 6 +- modules/nixos/common/hardware/default.nix | 1 + .../nixos/common/hardware/laptop-power.nix | 70 +++++++++++++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 modules/nixos/common/hardware/laptop-power.nix diff --git a/modules/home/gitconfigs/alias.conf b/modules/home/gitconfigs/alias.conf index b9825ce..b89b82a 100644 --- a/modules/home/gitconfigs/alias.conf +++ b/modules/home/gitconfigs/alias.conf @@ -30,6 +30,6 @@ sync = "!f() { \ clean-branches = "!f() { \ git for-each-ref --format '%(refname:short)' refs/heads| grep -v 'master\\|main' | xargs git branch -D ; \ }; f"; -# aliases = "!f() { \ -# git config --get-regexp alias | awk '{print $1}' | sed 's/alias\./ - /' \ -# }; f" \ No newline at end of file +aliases = "!f() { \ + git config --get-regexp alias | awk '{print $1}' | sed 's/alias\\./ - /' ; \ +}; f"; \ No newline at end of file diff --git a/modules/nixos/common/hardware/default.nix b/modules/nixos/common/hardware/default.nix index de181d9..a7a8a0d 100644 --- a/modules/nixos/common/hardware/default.nix +++ b/modules/nixos/common/hardware/default.nix @@ -4,6 +4,7 @@ ./fan2go.nix ./fancontrol.nix ./sound.nix + ./laptop-power.nix ]; # Firmware Updater services.fwupd.enable = true; diff --git a/modules/nixos/common/hardware/laptop-power.nix b/modules/nixos/common/hardware/laptop-power.nix new file mode 100644 index 0000000..66f8810 --- /dev/null +++ b/modules/nixos/common/hardware/laptop-power.nix @@ -0,0 +1,70 @@ +{ lib +, config +, ... +}: +let + cfg = config.skyg.nixos.common.hardware.laptop-power-mgr; +in +{ + options.skyg.nixos.common.hardware.laptop-power-mgr = with lib; { + enable = mkEnableOption "Settings for laptop power management"; + }; + + config = lib.mkIf cfg.enable { + # Advance Power Management + powerManagement.powertop.enable = true; + powerManagement.enable = true; + services.thermald.enable = true; + services.power-profiles-daemon.enable = false; + services.tlp = { + enable = true; + settings = { + TLP_DEFAULT_MODE = "BAT"; + TLP_PERSISTENT_DEFAULT = 1; + + CPU_BOOST_ON_BAT = 0; + RUNTIME_PM_ON_BAT = "auto"; + PLATFORM_PROFILE_ON_AC = "balanced"; + PLATFORM_PROFILE_ON_BAT = "low-power"; + + CPU_SCALING_GOVERNOR_ON_AC = "performance"; + CPU_SCALING_GOVERNOR_ON_BAT = "powersave"; + + CPU_ENERGY_PERF_POLICY_ON_BAT = "power"; + CPU_ENERGY_PERF_POLICY_ON_AC = "performance"; + + CPU_MIN_PERF_ON_AC = 0; + CPU_MAX_PERF_ON_AC = 100; + CPU_MIN_PERF_ON_BAT = 0; + CPU_MAX_PERF_ON_BAT = 20; + + START_CHARGE_THRESH_BAT0 = 40; # and bellow it starts to charge + STOP_CHARGE_THRESH_BAT0 = 97; # and above it stops charging + }; + }; + services.auto-cpufreq.enable = true; + services.auto-cpufreq.settings = { + battery = { + governor = "powersave"; + turbo = "never"; + }; + charger = { + governor = "performance"; + turbo = "auto"; + }; + }; + systemd.sleep.extraConfig = "HibernateDelaySec=30m"; + # Logind + services.logind = { + lidSwitchExternalPower = "suspend-then-hibernate"; + lidSwitch = "suspend-then-hibernate"; + powerKey = "lock"; + extraConfig = '' + LidSwitchIgnoreInhibited=yes + HandlePowerKey=suspend-then-hibernate + IdleAction=suspend-then-hibernate + IdleActionSec=2m + ''; + }; + }; +}