feat: nb add battery max charge option and quick change for it

This commit is contained in:
Dominik Polakovics Polakovics 2026-02-12 12:01:56 +01:00
parent 8f2a1e1357
commit 92a216c920
5 changed files with 136 additions and 73 deletions

View file

@ -5,9 +5,10 @@
{ config, lib, pkgs, ... }:
let
impermanence = builtins.fetchTarball "https://github.com/nix-community/impermanence/archive/master.tar.gz";
in {
in
{
nixpkgs.config.allowUnfree = true;
nixpkgs.config.allowBroken = true;
nixpkgs.config.allowBroken = true;
security.pki.certificates = [ "/home/dominik/.local/share/mkcert/rootCA.pem" ];
@ -30,6 +31,7 @@ in {
./modules/ollama.nix
./modules/qdrant.nix
./modules/battery-brightness.nix
./modules/charge-control.nix
./modules/suspend-fixes.nix
./cachix.nix
@ -71,9 +73,9 @@ in {
programs.zsh = {
enable = true;
ohMyZsh = {
enable = true; # Enable Oh My Zsh
theme = "steeef"; # Set theme
plugins = [ "git" ]; # Add plugins
enable = true; # Enable Oh My Zsh
theme = "steeef"; # Set theme
plugins = [ "git" ]; # Add plugins
};
interactiveShellInit = ''
# Bind Shift+Return to insert newline (foot terminal sends \e[27;2;13~)
@ -90,10 +92,10 @@ in {
# Disable irqbalance to save battery (not critical for laptop workloads)
services.irqbalance.enable = false;
swapDevices = [ {
swapDevices = [{
device = "/swap/swapfile";
size = 96 * 1024; # Size is in megabytes (96GB for full hibernation with 92GB RAM)
} ];
size = 96 * 1024; # Size is in megabytes (96GB for full hibernation with 92GB RAM)
}];
# Memory tuning for 92GB RAM
boot.kernel.sysctl = {
@ -102,8 +104,8 @@ in {
"vm.dirty_background_ratio" = 5;
"vm.vfs_cache_pressure" = 50;
# Battery optimization - increase dirty writeback time to batch writes
"vm.dirty_writeback_centisecs" = 3000; # 30 seconds (default: 500 = 5s)
"vm.dirty_expire_centisecs" = 3000; # 30 seconds (default: 3000)
"vm.dirty_writeback_centisecs" = 3000; # 30 seconds (default: 500 = 5s)
"vm.dirty_expire_centisecs" = 3000; # 30 seconds (default: 3000)
# Enable laptop mode for disk power management (2 = balanced, less aggressive than 5)
"vm.laptop_mode" = 2;
};
@ -131,7 +133,7 @@ in {
};
hardware.bluetooth.enable = true;
hardware.bluetooth.powerOnBoot = false; # Save battery - enable manually when needed
hardware.bluetooth.powerOnBoot = false; # Save battery - enable manually when needed
hardware.bluetooth.settings = {
General = { ControllerMode = "bredr"; };
};
@ -171,12 +173,12 @@ in {
sops.age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
sops.defaultSopsFile = ./secrets.yaml;
sops.secrets.epicenter_vpn_ca = {};
sops.secrets.epicenter_vpn_cert = {};
sops.secrets.epicenter_vpn_key = {};
sops.secrets.wg_private_key = {};
sops.secrets.wg_preshared_key = {};
sops.secrets.wg-cloonar-key = {};
sops.secrets.epicenter_vpn_ca = { };
sops.secrets.epicenter_vpn_cert = { };
sops.secrets.epicenter_vpn_key = { };
sops.secrets.wg_private_key = { };
sops.secrets.wg_preshared_key = { };
sops.secrets.wg-cloonar-key = { };
virtualisation.docker.enable = true;
services.flatpak.enable = true;
@ -189,7 +191,7 @@ in {
};
networking.hostName = "nb-01"; # Define your hostname.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
networking.networkmanager.enable = true; # Easiest to use and most distros use this by default.
networking.extraHosts = ''
77.119.230.30 vpn.cloonar.com
23.88.38.1 api.ebs.amz.at
@ -206,7 +208,7 @@ in {
extraGroups = [ "wheel" "disk" "video" "audio" "mysql" "docker" "vboxusers" "networkmanager" "onepassword" "onepassword-cli" "dialout" ]; # Enable sudo for the user.
};
users.groups.dominik = {};
users.groups.dominik = { };
environment.systemPackages = with pkgs; [
alsa-utils
@ -219,7 +221,7 @@ in {
TERMINAL_COMMAND = "alacritty";
MOZ_ENABLE_WAYLAND = "1";
};
services.blueman.enable = true;
security.rtkit.enable = true;
@ -241,21 +243,21 @@ in {
wants = [ "graphical-session.target" ];
after = [ "graphical-session.target" ];
serviceConfig = {
Type = "simple";
ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
Type = "simple";
ExecStart = "${pkgs.polkit_gnome}/libexec/polkit-gnome-authentication-agent-1";
Restart = "on-failure";
RestartSec = 1;
TimeoutStopSec = 10;
};
};
};
# pgp
services.pcscd.enable = true;
programs.gnupg.agent = {
enable = true;
enableSSHSupport = true;
pinentryPackage = pkgs.pinentry-curses;
enable = true;
enableSSHSupport = true;
pinentryPackage = pkgs.pinentry-curses;
};
nix = {