1{
2 lib,
3 stdenv,
4 buildPackages,
5 kernel,
6 pciutils,
7 gettext,
8 which,
9}:
10
11stdenv.mkDerivation {
12 pname = "cpupower";
13 inherit (kernel) version src patches;
14
15 nativeBuildInputs = [
16 gettext
17 which
18 ];
19 buildInputs = [ pciutils ];
20
21 postPatch = ''
22 cd tools/power/cpupower
23 sed -i 's,/bin/true,${buildPackages.coreutils}/bin/true,' Makefile
24 sed -i 's,/bin/pwd,${buildPackages.coreutils}/bin/pwd,' Makefile
25 sed -i 's,/usr/bin/install,${buildPackages.coreutils}/bin/install,' Makefile
26 '';
27
28 makeFlags = [
29 "CROSS=${stdenv.cc.targetPrefix}"
30 "CC=${stdenv.cc.targetPrefix}cc"
31 "LD=${stdenv.cc.targetPrefix}cc"
32 ];
33
34 installFlags = lib.mapAttrsToList (n: v: "${n}dir=${placeholder "out"}/${v}") {
35 bin = "bin";
36 sbin = "sbin";
37 man = "share/man";
38 include = "include";
39 lib = "lib";
40 libexec = "libexec";
41 locale = "share/locale";
42 doc = "share/doc/cpupower";
43 conf = "etc";
44 bash_completion_ = "share/bash-completion/completions";
45 unit = "lib/systemd/system";
46 };
47
48 enableParallelBuilding = true;
49
50 meta = with lib; {
51 description = "Tool to examine and tune power saving features";
52 homepage = "https://www.kernel.org/";
53 license = licenses.gpl2Only;
54 mainProgram = "cpupower";
55 platforms = platforms.linux;
56 };
57}