home

My NixOS systems configurations.
Log | Files | Refs | LICENSE

commit 50d13f5fe68411c37cd1b205215d39fe6f9aa1e7
parent 1929229af76dbafd9abc5b6a0bcfd0ff6494122f
Author: Vincent Demeester <vincent@sbr.pm>
Date:   Mon, 19 Sep 2022 15:57:48 +0200

systems/aomi: create 2 scripts for charge threshold

Signed-off-by: Vincent Demeester <vincent@sbr.pm>

Diffstat:
Msystems/hosts/aomi.nix | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/systems/hosts/aomi.nix b/systems/hosts/aomi.nix @@ -16,6 +16,16 @@ let endpointPort = if secretCondition then (import secretPath).wg.listenPort else 0; endpointPublicKey = strings.optionalString secretCondition (import secretPath).wireguard.kerkouane.publicKey; metadata = importTOML ../../ops/hosts.toml; + + # Scripts + officemode = pkgs.writeShellScriptBin "officemode" '' + echo "80" > /sys/class/power_supply/BAT0/charge_control_end_threshold + echo "70" > /sys/class/power_supply/BAT0/charge_control_start_threshold + ''; + roadmode = pkgs.writeShellScriptBin "roadmode" '' + echo "100" > /sys/class/power_supply/BAT0/charge_control_end_threshold + echo "99" > /sys/class/power_supply/BAT0/charge_control_start_threshold + ''; in { imports = [ @@ -53,6 +63,18 @@ in hostName = hostname; }; + environment.systemPackages = [ officemode roadmode ]; + security.sudo.extraRules = [ + # Allow execution of roadmode and officemode by users in wheel, without a password + { + groups = [ "wheel" ]; + commands = [ + { command = "${officemode}"; options = [ "NOPASSWD" ]; } + { command = "${roadmode}"; options = [ "NOPASSWD" ]; } + ]; + } + ]; + # extract this from desktop networking.networkmanager = { enable = true;