battery charge limit
This commit is contained in:
43
modules/nixos/hardware/battery/default.nix
Normal file
43
modules/nixos/hardware/battery/default.nix
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
# echo 81 | sudo tee /sys/class/power_supply/macsmc-battery/charge_control_end_threshold
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
pkgs,
|
||||||
|
lib,
|
||||||
|
namespace,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
with lib;
|
||||||
|
let
|
||||||
|
inherit (lib.${namespace}) mkOpt;
|
||||||
|
cfg = config.${namespace}.hardware.battery;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.${namespace}.hardware.battery = {
|
||||||
|
enable = mkEnableOption "battery charge limit service";
|
||||||
|
|
||||||
|
chargeLimit = mkOpt types.int 81 "Charge limit for the battery, ex: 81 = 80% charge limit";
|
||||||
|
|
||||||
|
battery = mkOpt types.str "" "Path to the battery charge limit file";
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
systemd = {
|
||||||
|
services = {
|
||||||
|
set-charge-limit = {
|
||||||
|
enable = true;
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
path = [
|
||||||
|
pkgs.uutils-coreutils-noprefix
|
||||||
|
];
|
||||||
|
script = ''
|
||||||
|
${pkgs.uutils-coreutils-noprefix}/bin/echo ${toString cfg.chargeLimit} | tee ${cfg.battery}
|
||||||
|
'';
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
TimeoutSec = "5s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -78,7 +78,7 @@ in
|
|||||||
environment = {
|
environment = {
|
||||||
systemPackages = with pkgs; [
|
systemPackages = with pkgs; [
|
||||||
attic-client
|
attic-client
|
||||||
uutils-coreutils
|
uutils-coreutils-noprefix
|
||||||
uutils-diffutils
|
uutils-diffutils
|
||||||
uutils-findutils
|
uutils-findutils
|
||||||
coreutils
|
coreutils
|
||||||
|
|||||||
@@ -7,7 +7,6 @@
|
|||||||
imports = [
|
imports = [
|
||||||
./boot.nix
|
./boot.nix
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
# ./networking.nix - moved to modules/nixos/network
|
|
||||||
./services.nix
|
./services.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
@@ -46,36 +45,12 @@
|
|||||||
};
|
};
|
||||||
gnome.enable = false;
|
gnome.enable = false;
|
||||||
};
|
};
|
||||||
# programs = {
|
hardware = {
|
||||||
# hyprland = {
|
battery = {
|
||||||
# enable = true;
|
enable = true;
|
||||||
# primaryDisplay = "eDP-1";
|
battery = " /sys/class/power_supply/macsmc-battery/charge_control_end_threshold";
|
||||||
|
};
|
||||||
# display1 = {
|
};
|
||||||
# input = "eDP-1";
|
|
||||||
# resolution = "3456x2234";
|
|
||||||
# refreshRate = "60.00000";
|
|
||||||
# };
|
|
||||||
|
|
||||||
# wallpaper = [
|
|
||||||
# "${display.input}, /run/wallpaper.jpg"
|
|
||||||
# ];
|
|
||||||
|
|
||||||
# monitor = [
|
|
||||||
# "${display.input},${display.resolution}@${display.refreshRate},0x0,1.25,bitdepth,10,cm,hdr,sdrbrightness,1.2,sdrsaturation,0.98"
|
|
||||||
# ];
|
|
||||||
|
|
||||||
# workspace = [
|
|
||||||
# "name:firefox, monitor:${display.input}, default:false, special, class:(.*firefox.*)"
|
|
||||||
# "name:discord, monitor:${display.input}, default:true, special, title:(.*vesktop.*), title:(.*Apple Music.*)"
|
|
||||||
# "name:steam, monitor:${display.input}, default:false, special, class:(.*[Ss]team.*)"
|
|
||||||
# ];
|
|
||||||
|
|
||||||
# windowRule = [
|
|
||||||
# "size 2160 3356, tag:horizonrdp"
|
|
||||||
# ];
|
|
||||||
# };
|
|
||||||
# };
|
|
||||||
network = {
|
network = {
|
||||||
hostName = "macbook-pro-nixos";
|
hostName = "macbook-pro-nixos";
|
||||||
networkmanager.enable = false;
|
networkmanager.enable = false;
|
||||||
|
|||||||
@@ -1,81 +0,0 @@
|
|||||||
let
|
|
||||||
theme = import ../../modules/desktop-environments/hyprland/theme.nix;
|
|
||||||
|
|
||||||
# Displays
|
|
||||||
display = {
|
|
||||||
input = "eDP-1";
|
|
||||||
resolution = "3456x2234";
|
|
||||||
refreshRate = "60.00000";
|
|
||||||
};
|
|
||||||
in
|
|
||||||
{
|
|
||||||
primaryDisplay = display;
|
|
||||||
networkInterface = "wlan0";
|
|
||||||
|
|
||||||
wallpaper = [
|
|
||||||
"${display.input}, /run/wallpaper.jpg"
|
|
||||||
];
|
|
||||||
|
|
||||||
monitor = [
|
|
||||||
"${display.input},${display.resolution}@${display.refreshRate},0x0,1.25,bitdepth,10,cm,hdr,sdrbrightness,1.2,sdrsaturation,0.98"
|
|
||||||
];
|
|
||||||
|
|
||||||
# monitorv2 = {
|
|
||||||
# output = "eDP-1";
|
|
||||||
# mode = "3456x2234@60.00000";
|
|
||||||
# position = "0x0";
|
|
||||||
# scale = "1.25";
|
|
||||||
# #bitdepth,10,cm,hdr,sdrbrightness,1.2,sdrsaturation,0.98"
|
|
||||||
# };
|
|
||||||
|
|
||||||
workspace = [
|
|
||||||
"name:firefox, monitor:${display.input}, default:false, special, class:(.*firefox.*)"
|
|
||||||
"name:discord, monitor:${display.input}, default:true, special, title:(.*vesktop.*), title:(.*Apple Music.*)"
|
|
||||||
"name:steam, monitor:${display.input}, default:false, special, class:(.*[Ss]team.*)"
|
|
||||||
];
|
|
||||||
|
|
||||||
windowRule = [
|
|
||||||
# "tag +fakefull, fullscreen: 0"
|
|
||||||
# "float, tag:fakefull"
|
|
||||||
# "size 3356 2160, tag:fakefull"
|
|
||||||
# "move 100 74, tag:fakefull"
|
|
||||||
# "noanim, tag:fakefull"
|
|
||||||
# "noblur, tag:fakefull"
|
|
||||||
# "norounding, tag:fakefull"
|
|
||||||
# "noshadow, tag:fakefull"
|
|
||||||
# "immediate, tag:fakefull"
|
|
||||||
# "noborder, tag:fakefull"
|
|
||||||
# "nodim, tag:fakefull"
|
|
||||||
# "idleinhibit, tag:fakefull"
|
|
||||||
"size 2160 3356, tag:horizonrdp"
|
|
||||||
];
|
|
||||||
|
|
||||||
waybar = {
|
|
||||||
layer = "top";
|
|
||||||
|
|
||||||
modules-right = [
|
|
||||||
"temperature"
|
|
||||||
"temperature#gpu"
|
|
||||||
"keyboard-state#capslock"
|
|
||||||
"keyboard-state#numlock"
|
|
||||||
"wireplumber#sink"
|
|
||||||
# "wireplumber#source"
|
|
||||||
"bluetooth"
|
|
||||||
"network"
|
|
||||||
"idle_inhibitor"
|
|
||||||
"clock"
|
|
||||||
"battery"
|
|
||||||
"custom/weather"
|
|
||||||
];
|
|
||||||
|
|
||||||
moduleStyle = {
|
|
||||||
window = {
|
|
||||||
margin-right = "75rem";
|
|
||||||
};
|
|
||||||
temperature = {
|
|
||||||
location = "${theme.waybar.borderLeft}";
|
|
||||||
border-radius = "1";
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
{ lib, ... }:
|
|
||||||
{
|
|
||||||
# Networking configs
|
|
||||||
networking = {
|
|
||||||
hostName = "macbook-pro-nixos";
|
|
||||||
|
|
||||||
wireless.iwd = {
|
|
||||||
enable = true;
|
|
||||||
settings = {
|
|
||||||
General = {
|
|
||||||
EnableNetworkConfiguration = true;
|
|
||||||
};
|
|
||||||
Rank = {
|
|
||||||
BandModifier2_4GHz = 1.0;
|
|
||||||
BandModifier5GHz = 5.0;
|
|
||||||
BandModifier6GHz = 10.0;
|
|
||||||
};
|
|
||||||
# DriverQuirks = {
|
|
||||||
# PowerSaveDisable = "hci_bcm4377,brcmfmac";
|
|
||||||
# };
|
|
||||||
Network = {
|
|
||||||
AutoConnect = true;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
# Enable Network Manager
|
|
||||||
networkmanager = {
|
|
||||||
enable = lib.mkForce false;
|
|
||||||
wifi = {
|
|
||||||
backend = lib.mkForce "iwd";
|
|
||||||
powersave = lib.mkDefault false;
|
|
||||||
};
|
|
||||||
settings.connectivity.uri = lib.mkDefault "http://nmcheck.gnome.org/check_network_status.txt";
|
|
||||||
};
|
|
||||||
|
|
||||||
# orca
|
|
||||||
firewall.extraCommands = ''
|
|
||||||
iptables -I INPUT -m pkttype --pkt-type multicast -j ACCEPT
|
|
||||||
iptables -A INPUT -m pkttype --pkt-type multicast -j ACCEPT
|
|
||||||
iptables -I INPUT -p udp -m udp --match multiport --dports 1990,2021 -j ACCEPT
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user