mirror of
https://github.com/ItsDrike/nixdots
synced 2024-12-28 17:34:35 +00:00
ItsDrike
00016063fe
Originally, I was including all role configurations for all hosts, and controlling which get applied in the role configs with a check in each file. This is a very repetetive and annoying approach. Instead, now the role directory is included manually from the hosts config for devices which meet that role, removing the role options.
38 lines
994 B
Nix
38 lines
994 B
Nix
{
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}: let
|
|
inherit (lib.modules) mkForce;
|
|
inherit (lib.strings) makeBinPath;
|
|
in {
|
|
# allows changing system behavior based upon user-selected power profiles
|
|
# (with `powerprofilesctl` command)
|
|
services.power-profiles-daemon.enable = true;
|
|
|
|
# Power state monitor. Switches power profiles based on charging state.
|
|
# Plugged in - performance (if available, falls back to balance)
|
|
# Unplugged - balanced, until below 50%, then power-saver
|
|
systemd.services."power-monitor" = let
|
|
dependencies = with pkgs; [
|
|
coreutils
|
|
gnugrep
|
|
power-profiles-daemon
|
|
inotify-tools
|
|
jaq
|
|
];
|
|
in {
|
|
description = "Power Monitoring Service";
|
|
environment.PATH = mkForce "/run/wrappers/bin:${makeBinPath dependencies}";
|
|
script = builtins.readFile ./power_monitor.sh;
|
|
|
|
serviceConfig = {
|
|
Type = "simple";
|
|
Restart = "on-failure";
|
|
};
|
|
|
|
wants = ["power-profiles-daemon.service"];
|
|
wantedBy = ["default.target"];
|
|
};
|
|
}
|