about summary refs log tree commit diff
path: root/nixpkgs/pkgs/os-specific/linux/powertop/default.nix
blob: 481cf1cd3bb514f8c932a7e4b304f1a855a78f8b (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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
{ lib
, stdenv
, fetchFromGitHub
, gettext
, libnl
, ncurses
, pciutils
, pkg-config
, zlib
, autoreconfHook
, autoconf-archive
, nix-update-script
, testers
, powertop
, xorg
}:

stdenv.mkDerivation rec {
  pname = "powertop";
  version = "2.15";

  src = fetchFromGitHub {
    owner = "fenrus75";
    repo = pname;
    rev = "v${version}";
    hash = "sha256-53jfqt0dtMqMj3W3m6ravUTzApLQcljDHfdXejeZa4M=";
  };

  outputs = [ "out" "man" ];

  nativeBuildInputs = [ pkg-config autoreconfHook autoconf-archive ];
  buildInputs = [ gettext libnl ncurses pciutils zlib ];

  postPatch = ''
    substituteInPlace src/main.cpp --replace "/sbin/modprobe" "modprobe"
    substituteInPlace src/calibrate/calibrate.cpp --replace "/usr/bin/xset" "${lib.getExe xorg.xset}"
    substituteInPlace src/tuning/bluetooth.cpp --replace "/usr/bin/hcitool" "hcitool"
  '';

  passthru = {
    updateScript = nix-update-script { };
    tests.version = testers.testVersion {
      package = powertop;
      command = "powertop --version";
      inherit version;
    };
  };

  meta = with lib; {
    inherit (src.meta) homepage;
    changelog = "https://github.com/fenrus75/powertop/releases/tag/v${version}";
    description = "Analyze power consumption on Intel-based laptops";
    license = licenses.gpl2Only;
    maintainers = with maintainers; [ fpletz anthonyroussel ];
    platforms = platforms.linux;
  };
}