1
0
Fork 0
mirror of https://github.com/NixOS/nixos-hardware synced 2024-11-17 00:19:42 +01:00
nixos-hardware/asus/battery.nix

22 lines
597 B
Nix
Raw Normal View History

2021-11-19 00:01:56 +01:00
{ config, pkgs, lib, ... }:
let
p = pkgs.writeScriptBin "charge-upto" ''
echo ''${0:-100} > /sys/class/power_supply/BAT0/charge_control_end_threshold
'';
cfg = config.hardware.asus;
in
{
options.hardware.asus.battery.chargeUpto = lib.mkOption {
2021-11-19 00:01:56 +01:00
description = "Maximum level of charge for your battery, as a percentage.";
default = 100;
type = lib.types.int;
};
config = {
environment.systemPackages = [ p ];
systemd.tmpfiles.rules = [
"w /sys/class/power_supply/BAT0/charge_control_end_threshold - - - - ${toString cfg.battery.chargeUpto}"
2021-11-19 00:01:56 +01:00
];
};
}