/nix-tools

Personal utility scripts and Nix tools

Primary LanguageNixGNU Affero General Public License v3.0AGPL-3.0

Hraban’s Misc Nix Tools

Various Nix utility scripts for my nix computers.

This is a sandbox for personal stuff, I make zero guarantees about any API or anything. I will try not to force push any existing commits, so if you want to use something, pin the specific revision in your flake’s inputs and you should be fine.

Battery Control for Mac (Intel and Apple Sillicon)

Use the battery-control nix-darwin module to control the maximum charge of your battery.

Example:

{
  inputs = {
    nix-tools.url = "github:hraban/nix-tools";
  };

  outputs = {
    nix-darwin
  , nix-tools
  , ...
  }: {
    darwinConfigurations = {
      MyHost = nix-darwin.lib.darwinSystem {
        # ...

        modules = [
          # Load the module here
          nix-tools.darwinModules.default

          # Now you can configure the actual module:
          ({ pkgs, ... }: {
            battery-control = {
              # (aarch64 only)
              # Use a clamping service to automatically turn charging...
              clamp-service = {
                enable = true;
                min = 10; # ON, when charge drops below this level
                max = 30; # OFF when charge rises above this level
                # "Charging off" means "maintain current level using power
                # supply", which is what you normally experience at 100%.
              };
              # Enable an xbar plugin to control the battery. On x86 this uses
              # BCLM and lets you select a “target charge” of between 50–100%,
              # while on aarch64 it provides a binary ON/OFF switch for
              # charging.  Requires xbar installed, of course, but also
              # home-manager.
              xbar-plugin.enable = true;
            };
          })
        ];
      };
    };
  };
}

License

Copyright © 2023–2024 Hraban Luyat

This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, version 3 of the License.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.

You should have received a copy of the GNU Affero General Public License along with this program. If not, see https://www.gnu.org/licenses/.