about summary refs log tree commit diff
path: root/nixpkgs/pkgs/os-specific/linux/tpacpi-bat/default.nix
blob: 42d8a0f9dbcfe3087f7065fb99b676626374fad7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{ lib, stdenv, fetchFromGitHub, perl, kmod, coreutils }:

# Requires the acpi_call kernel module in order to run.
stdenv.mkDerivation rec {
  pname = "tpacpi-bat";
  version = "3.2";

  src = fetchFromGitHub {
    owner = "teleshoes";
    repo = "tpacpi-bat";
    rev = "v${version}";
    sha256 = "sha256-9XnvVNdgB5VeI3juZfc8N5weEyULXuqu1IDChZfQqFk=";
  };

  buildInputs = [ perl ];

  installPhase = ''
    mkdir -p $out/bin
    cp tpacpi-bat $out/bin
  '';

  postPatch = ''
    substituteInPlace tpacpi-bat \
      --replace modprobe ${kmod}/bin/modprobe \
      --replace cat ${coreutils}/bin/cat
  '';

  meta = {
    maintainers = [lib.maintainers.orbekk];
    platforms = lib.platforms.linux;
    description = "Tool to set battery charging thresholds on Lenovo Thinkpad";
    mainProgram = "tpacpi-bat";
    license = lib.licenses.gpl3Plus;
  };
}